|
|
@ -30,6 +30,10 @@ namespace Fungus.EditorUtils |
|
|
|
private ReorderableList list; |
|
|
|
private ReorderableList list; |
|
|
|
public Flowchart TargetFlowchart { get; private set; } |
|
|
|
public Flowchart TargetFlowchart { get; private set; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private float[] itemWidths = new float[4]; |
|
|
|
|
|
|
|
private Rect[] itemRects = new Rect[4]; |
|
|
|
|
|
|
|
private GUIContent emptyGUIContent = new GUIContent(""); |
|
|
|
|
|
|
|
|
|
|
|
public SerializedProperty this[int index] |
|
|
|
public SerializedProperty this[int index] |
|
|
|
{ |
|
|
|
{ |
|
|
|
get { return _arrayProperty.GetArrayElementAtIndex(index); } |
|
|
|
get { return _arrayProperty.GetArrayElementAtIndex(index); } |
|
|
@ -111,8 +115,17 @@ namespace Fungus.EditorUtils |
|
|
|
if (_arrayProperty == null || _arrayProperty.serializedObject == null) |
|
|
|
if (_arrayProperty == null || _arrayProperty.serializedObject == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_arrayProperty.serializedObject.Update(); |
|
|
|
_arrayProperty.serializedObject.Update(); |
|
|
|
this.widthOfList = (w == 0 ? VariableListAdaptor.DefaultWidth : w) - ScrollSpacer; |
|
|
|
this.widthOfList = (w == 0 ? VariableListAdaptor.DefaultWidth : w) - ScrollSpacer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int width = widthOfList; |
|
|
|
|
|
|
|
int totalRatio = DefaultWidth; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
itemWidths[0] = (80.0f / totalRatio) * width; |
|
|
|
|
|
|
|
itemWidths[1] = (100.0f / totalRatio) * width; |
|
|
|
|
|
|
|
itemWidths[2] = (140.0f / totalRatio) * width; |
|
|
|
|
|
|
|
itemWidths[3] = (60.0f / totalRatio) * width; |
|
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Variables")) |
|
|
|
if (GUILayout.Button("Variables")) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -139,24 +152,14 @@ namespace Fungus.EditorUtils |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int width = widthOfList; |
|
|
|
|
|
|
|
int totalRatio = DefaultWidth; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float[] widths = { (80.0f/ totalRatio) * width, |
|
|
|
|
|
|
|
(100.0f / totalRatio) * width, |
|
|
|
|
|
|
|
(140.0f/ totalRatio) * width, |
|
|
|
|
|
|
|
(60.0f/ totalRatio) * width }; |
|
|
|
|
|
|
|
Rect[] rects = new Rect[4]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; ++i) |
|
|
|
for (int i = 0; i < 4; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
rects[i] = position; |
|
|
|
itemRects[i] = position; |
|
|
|
rects[i].width = widths[i] - 5; |
|
|
|
itemRects[i].width = itemWidths[i] - 5; |
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < i; ++j) |
|
|
|
for (int j = 0; j < i; ++j) |
|
|
|
{ |
|
|
|
{ |
|
|
|
rects[i].x += widths[j]; |
|
|
|
itemRects[i].x += itemWidths[j]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -213,14 +216,19 @@ namespace Fungus.EditorUtils |
|
|
|
|
|
|
|
|
|
|
|
variableObject.Update(); |
|
|
|
variableObject.Update(); |
|
|
|
|
|
|
|
|
|
|
|
GUI.Label(rects[0], variableInfo.VariableType); |
|
|
|
GUI.Label(itemRects[0], variableInfo.VariableType); |
|
|
|
|
|
|
|
|
|
|
|
key = EditorGUI.TextField(rects[1], variable.Key); |
|
|
|
|
|
|
|
SerializedProperty keyProp = variableObject.FindProperty("key"); |
|
|
|
SerializedProperty keyProp = variableObject.FindProperty("key"); |
|
|
|
SerializedProperty defaultProp = variableObject.FindProperty("value"); |
|
|
|
SerializedProperty defaultProp = variableObject.FindProperty("value"); |
|
|
|
SerializedProperty scopeProp = variableObject.FindProperty("scope"); |
|
|
|
SerializedProperty scopeProp = variableObject.FindProperty("scope"); |
|
|
|
|
|
|
|
|
|
|
|
keyProp.stringValue = flowchart.GetUniqueVariableKey(key, variable); |
|
|
|
|
|
|
|
|
|
|
|
EditorGUI.BeginChangeCheck(); |
|
|
|
|
|
|
|
key = EditorGUI.TextField(itemRects[1], variable.Key); |
|
|
|
|
|
|
|
if (EditorGUI.EndChangeCheck()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
keyProp.stringValue = flowchart.GetUniqueVariableKey(key, variable); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool isGlobal = scopeProp.enumValueIndex == (int)VariableScope.Global; |
|
|
|
bool isGlobal = scopeProp.enumValueIndex == (int)VariableScope.Global; |
|
|
|
|
|
|
|
|
|
|
@ -236,18 +244,18 @@ namespace Fungus.EditorUtils |
|
|
|
var prevEnabled = GUI.enabled; |
|
|
|
var prevEnabled = GUI.enabled; |
|
|
|
GUI.enabled = false; |
|
|
|
GUI.enabled = false; |
|
|
|
|
|
|
|
|
|
|
|
EditorGUI.PropertyField(rects[2], globalValProp, new GUIContent("")); |
|
|
|
EditorGUI.PropertyField(itemRects[2], globalValProp, emptyGUIContent); |
|
|
|
|
|
|
|
|
|
|
|
GUI.enabled = prevEnabled; |
|
|
|
GUI.enabled = prevEnabled; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
EditorGUI.PropertyField(rects[2], defaultProp, new GUIContent("")); |
|
|
|
EditorGUI.PropertyField(itemRects[2], defaultProp, emptyGUIContent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scope = (VariableScope)EditorGUI.EnumPopup(rects[3], variable.Scope); |
|
|
|
scope = (VariableScope)EditorGUI.EnumPopup(itemRects[3], variable.Scope); |
|
|
|
scopeProp.enumValueIndex = (int)scope; |
|
|
|
scopeProp.enumValueIndex = (int)scope; |
|
|
|
|
|
|
|
|
|
|
|
variableObject.ApplyModifiedProperties(); |
|
|
|
variableObject.ApplyModifiedProperties(); |
|
|
|