From d3ed078c9eb71271575d81e8f6317b188814490f Mon Sep 17 00:00:00 2001 From: Christopher Date: Wed, 25 Jan 2017 16:55:21 +0000 Subject: [PATCH] Added description fields to Invoke Event and Invoke Method --- Assets/Fungus/Scripts/Commands/InvokeEvent.cs | 8 ++++++++ Assets/Fungus/Scripts/Commands/InvokeMethod.cs | 8 ++++++++ Assets/Fungus/Scripts/Editor/InvokeEventEditor.cs | 3 +++ 3 files changed, 19 insertions(+) diff --git a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs index ee563bec..55c3e402 100644 --- a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs +++ b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs @@ -36,6 +36,9 @@ namespace Fungus [AddComponentMenu("")] public class InvokeEvent : Command { + [Tooltip("A description of what this command does. Appears in the command summary.")] + [SerializeField] protected string description = ""; + [Tooltip("Delay (in seconds) before the methods will be called")] [SerializeField] protected float delay; @@ -115,6 +118,11 @@ namespace Fungus public override string GetSummary() { + if (!string.IsNullOrEmpty(description)) + { + return description; + } + string summary = invokeType.ToString() + " "; switch (invokeType) diff --git a/Assets/Fungus/Scripts/Commands/InvokeMethod.cs b/Assets/Fungus/Scripts/Commands/InvokeMethod.cs index fd1ee6c5..ac438271 100644 --- a/Assets/Fungus/Scripts/Commands/InvokeMethod.cs +++ b/Assets/Fungus/Scripts/Commands/InvokeMethod.cs @@ -19,6 +19,9 @@ namespace Fungus "Invokes a method of a component via reflection. Supports passing multiple parameters and storing returned values in a Fungus variable.")] public class InvokeMethod : Command { + [Tooltip("A description of what this command does. Appears in the command summary.")] + [SerializeField] protected string description = ""; + [Tooltip("GameObject containing the component method to be invoked")] [SerializeField] protected GameObject targetObject; @@ -312,6 +315,11 @@ namespace Fungus return "Error: targetObject is not assigned"; } + if (!string.IsNullOrEmpty(description)) + { + return description; + } + return targetObject.name + "." + targetComponentText + "." + targetMethodText; } diff --git a/Assets/Fungus/Scripts/Editor/InvokeEventEditor.cs b/Assets/Fungus/Scripts/Editor/InvokeEventEditor.cs index 1724b95e..9e990846 100644 --- a/Assets/Fungus/Scripts/Editor/InvokeEventEditor.cs +++ b/Assets/Fungus/Scripts/Editor/InvokeEventEditor.cs @@ -8,6 +8,7 @@ namespace Fungus.EditorUtils [CustomEditor (typeof(InvokeEvent))] public class InvokeEventEditor : CommandEditor { + protected SerializedProperty descriptionProp; protected SerializedProperty delayProp; protected SerializedProperty invokeTypeProp; protected SerializedProperty staticEventProp; @@ -25,6 +26,7 @@ namespace Fungus.EditorUtils if (NullTargetCheck()) // Check for an orphaned editor instance return; + descriptionProp = serializedObject.FindProperty("description"); delayProp = serializedObject.FindProperty("delay"); invokeTypeProp = serializedObject.FindProperty("invokeType"); staticEventProp = serializedObject.FindProperty("staticEvent"); @@ -42,6 +44,7 @@ namespace Fungus.EditorUtils { serializedObject.Update(); + EditorGUILayout.PropertyField(descriptionProp); EditorGUILayout.PropertyField(delayProp); EditorGUILayout.PropertyField(invokeTypeProp);