You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
4.1 KiB
121 lines
4.1 KiB
10 years ago
|
using UnityEditor;
|
||
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace Fungus.Script
|
||
|
{
|
||
|
|
||
10 years ago
|
[CustomEditor (typeof(Call))]
|
||
|
public class CallEditor : FungusCommandEditor
|
||
10 years ago
|
{
|
||
|
public override void DrawCommandInspectorGUI()
|
||
|
{
|
||
10 years ago
|
serializedObject.Update();
|
||
|
|
||
10 years ago
|
Call t = target as Call;
|
||
10 years ago
|
|
||
|
FungusScript sc = t.GetFungusScript();
|
||
|
if (sc == null)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
10 years ago
|
CallCondition callCondition = (CallCondition)EditorGUILayout.EnumPopup(new GUIContent("Call Condition", "Condition when call will occur"), t.callCondition);
|
||
|
if (callCondition != t.callCondition)
|
||
10 years ago
|
{
|
||
10 years ago
|
Undo.RecordObject(t, "Set Call Condition");
|
||
|
t.callCondition = callCondition;
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
if (t.callCondition == CallCondition.CallAlways)
|
||
10 years ago
|
{
|
||
10 years ago
|
Sequence targetSequence = SequenceEditor.SequenceField(new GUIContent("Target Sequence", "Sequence to call"), t.GetFungusScript(), t.targetSequence);
|
||
10 years ago
|
if (targetSequence != t.targetSequence)
|
||
|
{
|
||
|
Undo.RecordObject(t, "Set Target Sequence");
|
||
|
t.targetSequence = targetSequence;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
10 years ago
|
FungusVariable fungusVariable = FungusVariableEditor.VariableField(new GUIContent("Compare Variable", "Variable to use in compare operation"),
|
||
|
t.GetFungusScript(),
|
||
|
t.variable,
|
||
|
null);
|
||
10 years ago
|
|
||
10 years ago
|
if (fungusVariable != t.variable)
|
||
10 years ago
|
{
|
||
|
Undo.RecordObject(t, "Select variable");
|
||
10 years ago
|
t.variable = fungusVariable;
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
if (t.variable == null)
|
||
10 years ago
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
List<GUIContent> operatorList = new List<GUIContent>();
|
||
|
operatorList.Add(new GUIContent("=="));
|
||
|
operatorList.Add(new GUIContent("!="));
|
||
10 years ago
|
if (t.variable.GetType() == typeof(IntegerVariable) ||
|
||
|
t.variable.GetType() == typeof(FloatVariable))
|
||
10 years ago
|
{
|
||
|
operatorList.Add(new GUIContent("<"));
|
||
|
operatorList.Add(new GUIContent(">"));
|
||
|
operatorList.Add(new GUIContent("<="));
|
||
|
operatorList.Add(new GUIContent(">="));
|
||
|
}
|
||
|
|
||
|
CompareOperator compareOperator = (CompareOperator)EditorGUILayout.Popup(new GUIContent("Operator",
|
||
|
"The comparison operator to use when comparing values"),
|
||
|
(int)t.compareOperator,
|
||
|
operatorList.ToArray());
|
||
|
if (compareOperator != t.compareOperator)
|
||
|
{
|
||
|
Undo.RecordObject(t, "Select compare operator");
|
||
|
t.compareOperator = compareOperator;
|
||
|
}
|
||
|
|
||
10 years ago
|
if (t.variable.GetType() == typeof(BooleanVariable))
|
||
10 years ago
|
{
|
||
10 years ago
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("booleanData"));
|
||
10 years ago
|
}
|
||
10 years ago
|
else if (t.variable.GetType() == typeof(IntegerVariable))
|
||
10 years ago
|
{
|
||
10 years ago
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("integerData"));
|
||
|
}
|
||
|
else if (t.variable.GetType() == typeof(FloatVariable))
|
||
|
{
|
||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("floatData"));
|
||
|
}
|
||
|
else if (t.variable.GetType() == typeof(StringVariable))
|
||
|
{
|
||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("stringData"));
|
||
10 years ago
|
}
|
||
|
|
||
|
Sequence onTrue = SequenceEditor.SequenceField(new GUIContent("On True Sequence", "Sequence to execute if comparision is true"),
|
||
|
t.GetFungusScript(),
|
||
|
t.onTrueSequence);
|
||
|
|
||
|
Sequence onFalse = SequenceEditor.SequenceField(new GUIContent("On False Sequence", "Sequence to execute if comparision is false"),
|
||
|
t.GetFungusScript(),
|
||
|
t.onFalseSequence);
|
||
|
|
||
|
if (onTrue != t.onTrueSequence)
|
||
|
{
|
||
|
Undo.RecordObject(t, "Set On True Sequence");
|
||
|
t.onTrueSequence = onTrue;
|
||
|
}
|
||
|
if (onFalse != t.onFalseSequence)
|
||
|
{
|
||
|
Undo.RecordObject(t, "Set On False Sequence");
|
||
|
t.onFalseSequence = onFalse;
|
||
|
}
|
||
10 years ago
|
|
||
|
serializedObject.ApplyModifiedProperties();
|
||
10 years ago
|
}
|
||
|
}
|
||
|
|
||
|
}
|