feat!: GetRequiredBehaviour/HierarchyObject methods added for cleaner null handling

This commit is contained in:
2025-04-13 12:52:27 +03:00
parent bfbcfdce4f
commit 86b8cd9b55
21 changed files with 140 additions and 73 deletions

View File

@@ -8,7 +8,7 @@ public abstract class Behaviour2D : Behaviour, IBehaviour2D
protected sealed override void OnInitialize(IInitializable _)
{
Transform = BehaviourController.GetBehaviourInChildren<ITransform2D>() ?? throw new($"{HierarchyObject.Name} does not contain any {nameof(ITransform2D)}");
Transform = BehaviourController.GetRequiredBehaviour<ITransform2D>();
base.OnInitialize(_);
}