diff --git a/Engine.Core/Extensions/BehaviourControllerExtensions.cs b/Engine.Core/Extensions/BehaviourControllerExtensions.cs index 3f71685..435c9c1 100644 --- a/Engine.Core/Extensions/BehaviourControllerExtensions.cs +++ b/Engine.Core/Extensions/BehaviourControllerExtensions.cs @@ -27,7 +27,7 @@ public static class BehaviourControllerExtensions /// The to start searching from. /// The of the specified type if found; otherwise, throws . public static T GetRequiredBehaviour(this IBehaviourController behaviourController) where T : class - => behaviourController.GetBehaviour() ?? throw new BehaviourNotFoundException($"{behaviourController.UniverseObject.Name}'s {nameof(IBehaviourController)} does not contain any {typeof(T).FullName}"); + => behaviourController.GetBehaviour() ?? throw new BehaviourNotFoundException($"{behaviourController.UniverseObject?.Name ?? "NULL"}'s {nameof(IBehaviourController)} does not contain any {typeof(T).FullName}"); /// /// Gets an existing of the specified type, or adds and returns a new one if it doesn't exist. @@ -93,7 +93,7 @@ public static class BehaviourControllerExtensions /// The to start searching from. /// The of the specified type if found; otherwise, throws . public static T GetRequiredBehaviourInParent(this IBehaviourController behaviourController) where T : class - => behaviourController.GetBehaviourInParent() ?? throw new BehaviourNotFoundException($"{behaviourController.UniverseObject.Name}'s {nameof(IBehaviourController)} does not contain any {typeof(T).FullName} on any parent"); + => behaviourController.GetBehaviourInParent() ?? throw new BehaviourNotFoundException($"{behaviourController.UniverseObject?.Name ?? "NULL"}'s {nameof(IBehaviourController)} does not contain any {typeof(T).FullName} on any parent"); /// /// Gets all s of the specified type in it's 's parents recursively and stores them in the provided list. @@ -154,7 +154,7 @@ public static class BehaviourControllerExtensions /// The to start searching from. /// The of the specified type if found; otherwise, throws . public static T GetRequiredBehaviourInChildren(this IBehaviourController behaviourController) where T : class - => behaviourController.GetBehaviourInChildren() ?? throw new BehaviourNotFoundException($"{behaviourController.UniverseObject.Name}'s {nameof(IBehaviourController)} does not contain any {typeof(T).FullName} on any children "); + => behaviourController.GetBehaviourInChildren() ?? throw new BehaviourNotFoundException($"{behaviourController.UniverseObject?.Name ?? "NULL"}'s {nameof(IBehaviourController)} does not contain any {typeof(T).FullName} on any children "); /// /// Gets all s of the specified type in it's 's children recursively and stores them in the provided list.