From bebf66e2187c289550c35e5d978587253b39ad27 Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 23 Aug 2016 13:01:38 +0100 Subject: [PATCH] Refactored ExecuteHandler --- .../Scripts/Editor/ExecuteHandlerEditor.cs | 46 +++++++++---------- .../FungusLua/Scripts/ExecuteHandler.cs | 38 +++++++++++---- 2 files changed, 52 insertions(+), 32 deletions(-) diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/ExecuteHandlerEditor.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/ExecuteHandlerEditor.cs index 9ddf2672..15629861 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/ExecuteHandlerEditor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/ExecuteHandlerEditor.cs @@ -42,7 +42,7 @@ namespace Fungus var executeHandler = (ExecuteHandler)target; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("On Event")); - executeHandler.executeMethods = (ExecuteHandler.ExecuteMethod)EditorGUILayout.EnumMaskField(executeHandler.executeMethods, + executeHandler.ExecuteMethods = (ExecuteHandler.ExecuteMethod)EditorGUILayout.EnumMaskField(executeHandler.ExecuteMethods, EditorStyles.popup, GUILayout.ExpandWidth(false)); EditorGUILayout.EndHorizontal(); @@ -75,36 +75,36 @@ namespace Fungus private void DrawOptionsForAfterPeriodOfTime(ExecuteHandler executeHandler) { EditorGUILayout.Space(); - executeHandler.executeAfterTime = EditorGUILayout.FloatField(m_GUIExecuteAfterTimeGuiContent, - executeHandler.executeAfterTime); - if (executeHandler.executeAfterTime < 0) - executeHandler.executeAfterTime = 0; - executeHandler.repeatExecuteTime = EditorGUILayout.Toggle(m_GUIRepeatExecuteTimeGuiContent, - executeHandler.repeatExecuteTime); - if (executeHandler.repeatExecuteTime) + executeHandler.ExecuteAfterTime = EditorGUILayout.FloatField(m_GUIExecuteAfterTimeGuiContent, + executeHandler.ExecuteAfterTime); + if (executeHandler.ExecuteAfterTime < 0) + executeHandler.ExecuteAfterTime = 0; + executeHandler.RepeatExecuteTime = EditorGUILayout.Toggle(m_GUIRepeatExecuteTimeGuiContent, + executeHandler.RepeatExecuteTime); + if (executeHandler.RepeatExecuteTime) { - executeHandler.repeatEveryTime = EditorGUILayout.FloatField(m_GUIRepeatEveryTimeGuiContent, - executeHandler.repeatEveryTime); - if (executeHandler.repeatEveryTime < 0) - executeHandler.repeatEveryTime = 0; + executeHandler.RepeatEveryTime = EditorGUILayout.FloatField(m_GUIRepeatEveryTimeGuiContent, + executeHandler.RepeatEveryTime); + if (executeHandler.RepeatEveryTime < 0) + executeHandler.RepeatEveryTime = 0; } } private void DrawOptionsForOnUpdate(ExecuteHandler executeHandler) { EditorGUILayout.Space(); - executeHandler.executeAfterFrames = EditorGUILayout.IntField(m_GUIExecuteAfterFramesGuiContent, - executeHandler.executeAfterFrames); - if (executeHandler.executeAfterFrames < 1) - executeHandler.executeAfterFrames = 1; - executeHandler.repeatExecuteFrame = EditorGUILayout.Toggle(m_GUIRepeatExecuteFrameGuiContent, - executeHandler.repeatExecuteFrame); - if (executeHandler.repeatExecuteFrame) + executeHandler.ExecuteAfterFrames = EditorGUILayout.IntField(m_GUIExecuteAfterFramesGuiContent, + executeHandler.ExecuteAfterFrames); + if (executeHandler.ExecuteAfterFrames < 1) + executeHandler.ExecuteAfterFrames = 1; + executeHandler.RepeatExecuteFrame = EditorGUILayout.Toggle(m_GUIRepeatExecuteFrameGuiContent, + executeHandler.RepeatExecuteFrame); + if (executeHandler.RepeatExecuteFrame) { - executeHandler.repeatEveryFrame = EditorGUILayout.IntField(m_GUIRepeatEveryTimeGuiContent, - executeHandler.repeatEveryFrame); - if (executeHandler.repeatEveryFrame < 1) - executeHandler.repeatEveryFrame = 1; + executeHandler.RepeatEveryFrame = EditorGUILayout.IntField(m_GUIRepeatEveryTimeGuiContent, + executeHandler.RepeatEveryFrame); + if (executeHandler.RepeatEveryFrame < 1) + executeHandler.RepeatEveryFrame = 1; } } } diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs index 32b1d149..3649ec39 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs @@ -52,15 +52,35 @@ namespace Fungus OnCollisionStay2D = 1 << 24, } - [SerializeField] public float executeAfterTime = 1f; - [SerializeField] public bool repeatExecuteTime = true; - [SerializeField] public float repeatEveryTime = 1f; - [SerializeField] public int executeAfterFrames = 1; - [SerializeField] public bool repeatExecuteFrame = true; - [SerializeField] public int repeatEveryFrame = 1; - [SerializeField] public bool hasFailed; - - [SerializeField] public ExecuteMethod executeMethods = ExecuteMethod.Start; + [SerializeField] protected float executeAfterTime = 1f; + + public float ExecuteAfterTime { get { return executeAfterTime; } set { executeAfterTime = value; } } + + [SerializeField] protected bool repeatExecuteTime = true; + + public bool RepeatExecuteTime { get { return repeatExecuteTime; } set { repeatExecuteTime = value; } } + + [SerializeField] protected float repeatEveryTime = 1f; + + public float RepeatEveryTime { get { return repeatEveryTime; } set { repeatEveryTime = value; } } + + [SerializeField] protected int executeAfterFrames = 1; + + public int ExecuteAfterFrames { get { return executeAfterFrames; } set { executeAfterFrames = value; } } + + [SerializeField] protected bool repeatExecuteFrame = true; + + public bool RepeatExecuteFrame { get { return repeatExecuteFrame; } set { repeatExecuteFrame = value; } } + + [SerializeField] protected int repeatEveryFrame = 1; + + public int RepeatEveryFrame { get { return repeatEveryFrame; } set { repeatEveryFrame = value; } } + + [SerializeField] protected bool hasFailed; + + [SerializeField] protected ExecuteMethod executeMethods = ExecuteMethod.Start; + + public ExecuteMethod ExecuteMethods { get { return executeMethods; } set { executeMethods = value; } } [Tooltip("Name of the method on a component in this gameobject to call when executing.")] [SerializeField] protected string executeMethodName = "OnExecute";