From 0fb3237c6f21a3014123ff6256d46f532d619ce6 Mon Sep 17 00:00:00 2001 From: Karim Kimsanbaev Date: Sun, 10 Sep 2023 17:18:02 +0300 Subject: [PATCH] View bonsai window with interface --- Core/BonsaiTreeComponent.cs | 2 +- Core/IViewInBonsaiTreeWindow.cs | 7 +++++++ Core/IViewInBonsaiTreeWindow.cs.meta | 3 +++ Editor/BonsaiWindow.cs | 4 ++-- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 Core/IViewInBonsaiTreeWindow.cs create mode 100644 Core/IViewInBonsaiTreeWindow.cs.meta diff --git a/Core/BonsaiTreeComponent.cs b/Core/BonsaiTreeComponent.cs index a59d90b..9150bfc 100644 --- a/Core/BonsaiTreeComponent.cs +++ b/Core/BonsaiTreeComponent.cs @@ -3,7 +3,7 @@ namespace Bonsai.Core { - public class BonsaiTreeComponent : MonoBehaviour + public class BonsaiTreeComponent : MonoBehaviour, IViewInBonsaiTreeWindow { /// /// The tree blueprint asset used. diff --git a/Core/IViewInBonsaiTreeWindow.cs b/Core/IViewInBonsaiTreeWindow.cs new file mode 100644 index 0000000..0474cf7 --- /dev/null +++ b/Core/IViewInBonsaiTreeWindow.cs @@ -0,0 +1,7 @@ +namespace Bonsai.Core +{ + public interface IViewInBonsaiTreeWindow + { + BehaviourTree Tree { get; } + } +} \ No newline at end of file diff --git a/Core/IViewInBonsaiTreeWindow.cs.meta b/Core/IViewInBonsaiTreeWindow.cs.meta new file mode 100644 index 0000000..a8b601d --- /dev/null +++ b/Core/IViewInBonsaiTreeWindow.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2dc34805bf0f40c9863deb6c32a30c77 +timeCreated: 1694337859 \ No newline at end of file diff --git a/Editor/BonsaiWindow.cs b/Editor/BonsaiWindow.cs index 8f07e3a..98d3667 100644 --- a/Editor/BonsaiWindow.cs +++ b/Editor/BonsaiWindow.cs @@ -178,8 +178,8 @@ private void SwitchToViewModeIfRequired() return; } - var btc = Selection.activeGameObject.GetComponent(); - BehaviourTree treeToView = btc ? btc.Tree : null; + var btc = Selection.activeGameObject.GetComponent(); + BehaviourTree treeToView = btc != null ? btc.Tree : null; // There must be a non-null tree to view, // it must be a different tree than the active tree for this window,