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.
84 lines
2.6 KiB
84 lines
2.6 KiB
10 years ago
|
using UnityEditor;
|
||
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace Fungus.Script
|
||
|
{
|
||
|
|
||
10 years ago
|
[CustomEditor (typeof(If))]
|
||
|
public class IfEditor : FungusCommandEditor
|
||
10 years ago
|
{
|
||
10 years ago
|
public override void DrawCommandGUI()
|
||
10 years ago
|
{
|
||
10 years ago
|
serializedObject.Update();
|
||
10 years ago
|
|
||
10 years ago
|
If t = target as If;
|
||
10 years ago
|
|
||
10 years ago
|
FungusScript fungusScript = t.GetFungusScript();
|
||
|
if (fungusScript == null)
|
||
10 years ago
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
10 years ago
|
FungusVariable fungusVariable = FungusVariableEditor.VariableField(new GUIContent("Variable", "Variable to use in operation"),
|
||
10 years ago
|
t.GetFungusScript(),
|
||
|
t.variable,
|
||
|
null);
|
||
10 years ago
|
|
||
10 years ago
|
if (fungusVariable != t.variable)
|
||
10 years ago
|
{
|
||
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(">="));
|
||
|
}
|
||
|
|
||
10 years ago
|
CompareOperator compareOperator = (CompareOperator)EditorGUILayout.Popup(new GUIContent("Compare",
|
||
10 years ago
|
"The comparison operator to use when comparing values"),
|
||
|
(int)t.compareOperator,
|
||
|
operatorList.ToArray());
|
||
|
if (compareOperator != t.compareOperator)
|
||
|
{
|
||
10 years ago
|
Undo.RecordObject(t, "Select Compare Operator");
|
||
10 years ago
|
t.compareOperator = compareOperator;
|
||
|
}
|
||
|
|
||
10 years ago
|
if (t.variable.GetType() == typeof(BooleanVariable))
|
||
10 years ago
|
{
|
||
10 years ago
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("booleanValue"));
|
||
10 years ago
|
}
|
||
10 years ago
|
else if (t.variable.GetType() == typeof(IntegerVariable))
|
||
10 years ago
|
{
|
||
10 years ago
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("integerValue"));
|
||
10 years ago
|
}
|
||
|
else if (t.variable.GetType() == typeof(FloatVariable))
|
||
|
{
|
||
10 years ago
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("floatValue"));
|
||
10 years ago
|
}
|
||
|
else if (t.variable.GetType() == typeof(StringVariable))
|
||
|
{
|
||
10 years ago
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("stringValue"));
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
serializedObject.ApplyModifiedProperties();
|
||
10 years ago
|
}
|
||
|
}
|
||
|
|
||
|
}
|