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.
85 lines
2.4 KiB
85 lines
2.4 KiB
10 years ago
|
using UnityEditor;
|
||
10 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
10 years ago
|
using System.Collections.Generic;
|
||
10 years ago
|
|
||
10 years ago
|
namespace Fungus.Script
|
||
10 years ago
|
{
|
||
|
|
||
10 years ago
|
[CustomEditor (typeof(Set))]
|
||
10 years ago
|
public class SetEditor : FungusCommandEditor
|
||
10 years ago
|
{
|
||
|
public override void DrawCommandInspectorGUI()
|
||
10 years ago
|
{
|
||
10 years ago
|
Set t = target as Set;
|
||
10 years ago
|
|
||
10 years ago
|
FungusScript fungusScript = t.GetFungusScript();
|
||
10 years ago
|
if (fungusScript == null)
|
||
10 years ago
|
{
|
||
10 years ago
|
return;
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
VariableType variableType = VariableType.Boolean;
|
||
|
string variableKey = SequenceEditor.VariableField(new GUIContent("Variable", "Variable to set"),
|
||
|
fungusScript,
|
||
|
t.variableKey,
|
||
|
ref variableType);
|
||
10 years ago
|
|
||
10 years ago
|
|
||
|
if (variableKey != t.variableKey)
|
||
10 years ago
|
{
|
||
10 years ago
|
Undo.RecordObject(t, "Set Variable Key");
|
||
|
t.variableKey = variableKey;
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
if (t.variableKey == "<None>")
|
||
10 years ago
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
10 years ago
|
bool booleanValue = t.booleanData.value;
|
||
|
int integerValue = t.integerData.value;
|
||
|
float floatValue = t.floatData.value;
|
||
|
string stringValue = t.stringData.value;
|
||
10 years ago
|
|
||
10 years ago
|
switch (variableType)
|
||
10 years ago
|
{
|
||
|
case VariableType.Boolean:
|
||
10 years ago
|
booleanValue = EditorGUILayout.Toggle(new GUIContent("Boolean Value", "The boolean value to set the variable with"), booleanValue);
|
||
10 years ago
|
break;
|
||
|
case VariableType.Integer:
|
||
10 years ago
|
integerValue = EditorGUILayout.IntField(new GUIContent("Integer Value", "The integer value to set the variable with"), integerValue);
|
||
10 years ago
|
break;
|
||
|
case VariableType.Float:
|
||
10 years ago
|
floatValue = EditorGUILayout.FloatField(new GUIContent("Float Value", "The float value to set the variable with"), floatValue);
|
||
10 years ago
|
break;
|
||
|
case VariableType.String:
|
||
10 years ago
|
stringValue = EditorGUILayout.TextField(new GUIContent("String Value", "The string value to set the variable with"), stringValue);
|
||
10 years ago
|
break;
|
||
|
}
|
||
|
|
||
10 years ago
|
if (booleanValue != t.booleanData.value)
|
||
10 years ago
|
{
|
||
|
Undo.RecordObject(t, "Set boolean value");
|
||
10 years ago
|
t.booleanData.value = booleanValue;
|
||
10 years ago
|
}
|
||
10 years ago
|
else if (integerValue != t.integerData.value)
|
||
10 years ago
|
{
|
||
|
Undo.RecordObject(t, "Set integer value");
|
||
10 years ago
|
t.integerData.value = integerValue;
|
||
10 years ago
|
}
|
||
10 years ago
|
else if (floatValue != t.floatData.value)
|
||
10 years ago
|
{
|
||
|
Undo.RecordObject(t, "Set float value");
|
||
10 years ago
|
t.floatData.value = floatValue;
|
||
10 years ago
|
}
|
||
10 years ago
|
else if (stringValue != t.stringData.value)
|
||
10 years ago
|
{
|
||
|
Undo.RecordObject(t, "Set string value");
|
||
10 years ago
|
t.stringData.value = stringValue;
|
||
10 years ago
|
}
|
||
|
}
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
}
|