Browse Source

Refactored ExecuteHandler

master
Christopher 9 years ago
parent
commit
bebf66e218
  1. 46
      Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/ExecuteHandlerEditor.cs
  2. 38
      Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs

46
Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/ExecuteHandlerEditor.cs vendored

@ -42,7 +42,7 @@ namespace Fungus
var executeHandler = (ExecuteHandler)target; var executeHandler = (ExecuteHandler)target;
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(new GUIContent("On Event")); EditorGUILayout.PrefixLabel(new GUIContent("On Event"));
executeHandler.executeMethods = (ExecuteHandler.ExecuteMethod)EditorGUILayout.EnumMaskField(executeHandler.executeMethods, executeHandler.ExecuteMethods = (ExecuteHandler.ExecuteMethod)EditorGUILayout.EnumMaskField(executeHandler.ExecuteMethods,
EditorStyles.popup, EditorStyles.popup,
GUILayout.ExpandWidth(false)); GUILayout.ExpandWidth(false));
EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal();
@ -75,36 +75,36 @@ namespace Fungus
private void DrawOptionsForAfterPeriodOfTime(ExecuteHandler executeHandler) private void DrawOptionsForAfterPeriodOfTime(ExecuteHandler executeHandler)
{ {
EditorGUILayout.Space(); EditorGUILayout.Space();
executeHandler.executeAfterTime = EditorGUILayout.FloatField(m_GUIExecuteAfterTimeGuiContent, executeHandler.ExecuteAfterTime = EditorGUILayout.FloatField(m_GUIExecuteAfterTimeGuiContent,
executeHandler.executeAfterTime); executeHandler.ExecuteAfterTime);
if (executeHandler.executeAfterTime < 0) if (executeHandler.ExecuteAfterTime < 0)
executeHandler.executeAfterTime = 0; executeHandler.ExecuteAfterTime = 0;
executeHandler.repeatExecuteTime = EditorGUILayout.Toggle(m_GUIRepeatExecuteTimeGuiContent, executeHandler.RepeatExecuteTime = EditorGUILayout.Toggle(m_GUIRepeatExecuteTimeGuiContent,
executeHandler.repeatExecuteTime); executeHandler.RepeatExecuteTime);
if (executeHandler.repeatExecuteTime) if (executeHandler.RepeatExecuteTime)
{ {
executeHandler.repeatEveryTime = EditorGUILayout.FloatField(m_GUIRepeatEveryTimeGuiContent, executeHandler.RepeatEveryTime = EditorGUILayout.FloatField(m_GUIRepeatEveryTimeGuiContent,
executeHandler.repeatEveryTime); executeHandler.RepeatEveryTime);
if (executeHandler.repeatEveryTime < 0) if (executeHandler.RepeatEveryTime < 0)
executeHandler.repeatEveryTime = 0; executeHandler.RepeatEveryTime = 0;
} }
} }
private void DrawOptionsForOnUpdate(ExecuteHandler executeHandler) private void DrawOptionsForOnUpdate(ExecuteHandler executeHandler)
{ {
EditorGUILayout.Space(); EditorGUILayout.Space();
executeHandler.executeAfterFrames = EditorGUILayout.IntField(m_GUIExecuteAfterFramesGuiContent, executeHandler.ExecuteAfterFrames = EditorGUILayout.IntField(m_GUIExecuteAfterFramesGuiContent,
executeHandler.executeAfterFrames); executeHandler.ExecuteAfterFrames);
if (executeHandler.executeAfterFrames < 1) if (executeHandler.ExecuteAfterFrames < 1)
executeHandler.executeAfterFrames = 1; executeHandler.ExecuteAfterFrames = 1;
executeHandler.repeatExecuteFrame = EditorGUILayout.Toggle(m_GUIRepeatExecuteFrameGuiContent, executeHandler.RepeatExecuteFrame = EditorGUILayout.Toggle(m_GUIRepeatExecuteFrameGuiContent,
executeHandler.repeatExecuteFrame); executeHandler.RepeatExecuteFrame);
if (executeHandler.repeatExecuteFrame) if (executeHandler.RepeatExecuteFrame)
{ {
executeHandler.repeatEveryFrame = EditorGUILayout.IntField(m_GUIRepeatEveryTimeGuiContent, executeHandler.RepeatEveryFrame = EditorGUILayout.IntField(m_GUIRepeatEveryTimeGuiContent,
executeHandler.repeatEveryFrame); executeHandler.RepeatEveryFrame);
if (executeHandler.repeatEveryFrame < 1) if (executeHandler.RepeatEveryFrame < 1)
executeHandler.repeatEveryFrame = 1; executeHandler.RepeatEveryFrame = 1;
} }
} }
} }

38
Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs vendored

@ -52,15 +52,35 @@ namespace Fungus
OnCollisionStay2D = 1 << 24, OnCollisionStay2D = 1 << 24,
} }
[SerializeField] public float executeAfterTime = 1f; [SerializeField] protected float executeAfterTime = 1f;
[SerializeField] public bool repeatExecuteTime = true;
[SerializeField] public float repeatEveryTime = 1f; public float ExecuteAfterTime { get { return executeAfterTime; } set { executeAfterTime = value; } }
[SerializeField] public int executeAfterFrames = 1;
[SerializeField] public bool repeatExecuteFrame = true; [SerializeField] protected bool repeatExecuteTime = true;
[SerializeField] public int repeatEveryFrame = 1;
[SerializeField] public bool hasFailed; public bool RepeatExecuteTime { get { return repeatExecuteTime; } set { repeatExecuteTime = value; } }
[SerializeField] public ExecuteMethod executeMethods = ExecuteMethod.Start; [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.")] [Tooltip("Name of the method on a component in this gameobject to call when executing.")]
[SerializeField] protected string executeMethodName = "OnExecute"; [SerializeField] protected string executeMethodName = "OnExecute";

Loading…
Cancel
Save