From d1d2041800bb513d9e8cab11b826dae4259522ff Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Fri, 21 Nov 2014 15:00:09 +0000 Subject: [PATCH] Hide Components option now unhides all components when not selected Added Fungus Script to component menu --- .../FungusScript/Scripts/FungusScript.cs | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs index dfae7c38..b623e305 100644 --- a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs +++ b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs @@ -11,6 +11,7 @@ namespace Fungus * Visual scripting controller for the Fungus Script programming language. * FungusScript objects may be edited visually using the Fungus Script editor window. */ + [AddComponentMenu("Fungus/Fungus Script")] public class FungusScript : MonoBehaviour { /** @@ -368,27 +369,45 @@ namespace Fungus */ public virtual void UpdateHideFlags() { - Sequence[] sequences = GetComponentsInChildren(); - foreach (Sequence sequence in sequences) + if (hideComponents) { - sequence.hideFlags = hideComponents ? HideFlags.HideInInspector : HideFlags.None; - if (sequence.gameObject != gameObject) + Sequence[] sequences = GetComponentsInChildren(); + foreach (Sequence sequence in sequences) { - sequence.gameObject.hideFlags = hideComponents ? HideFlags.HideInHierarchy : HideFlags.None; + sequence.hideFlags = HideFlags.HideInInspector; + if (sequence.gameObject != gameObject) + { + sequence.gameObject.hideFlags = HideFlags.HideInHierarchy; + } } - } - Command[] commands = GetComponentsInChildren(); - foreach (Command command in commands) - { - command.hideFlags = hideComponents ? HideFlags.HideInInspector : HideFlags.None; - } + Command[] commands = GetComponentsInChildren(); + foreach (Command command in commands) + { + command.hideFlags = HideFlags.HideInInspector; + } - EventHandler[] eventHandlers = GetComponentsInChildren(); - foreach (EventHandler eventHandler in eventHandlers) + EventHandler[] eventHandlers = GetComponentsInChildren(); + foreach (EventHandler eventHandler in eventHandlers) + { + eventHandler.hideFlags = HideFlags.HideInInspector; + } + } + else { - eventHandler.hideFlags = hideComponents ? HideFlags.HideInInspector : HideFlags.None; + MonoBehaviour[] monoBehaviours = GetComponentsInChildren(); + foreach (MonoBehaviour monoBehaviour in monoBehaviours) + { + if (monoBehaviour == null) + { + continue; + } + + monoBehaviour.hideFlags = HideFlags.None; + monoBehaviour.gameObject.hideFlags = HideFlags.None; + } } + } public virtual void ClearSelectedCommands()