|
|
|
@ -8,7 +8,8 @@ using UnityEditorInternal;
|
|
|
|
|
|
|
|
|
|
namespace Fungus.EditorUtils |
|
|
|
|
{ |
|
|
|
|
public class CommandListAdaptor { |
|
|
|
|
public class CommandListAdaptor |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
public void DrawCommandList() |
|
|
|
|
{ |
|
|
|
@ -32,29 +33,37 @@ namespace Fungus.EditorUtils
|
|
|
|
|
|
|
|
|
|
public float fixedItemHeight; |
|
|
|
|
|
|
|
|
|
public SerializedProperty this[int index] { |
|
|
|
|
public SerializedProperty this[int index] |
|
|
|
|
{ |
|
|
|
|
get { return _arrayProperty.GetArrayElementAtIndex(index); } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public SerializedProperty arrayProperty { |
|
|
|
|
public SerializedProperty arrayProperty |
|
|
|
|
{ |
|
|
|
|
get { return _arrayProperty; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CommandListAdaptor(Block _block, SerializedProperty arrayProperty, float fixedItemHeight = 0) { |
|
|
|
|
public CommandListAdaptor(Block _block, SerializedProperty arrayProperty) |
|
|
|
|
{ |
|
|
|
|
if (arrayProperty == null) |
|
|
|
|
throw new ArgumentNullException("Array property was null."); |
|
|
|
|
if (!arrayProperty.isArray) |
|
|
|
|
throw new InvalidOperationException("Specified serialized propery is not an array."); |
|
|
|
|
|
|
|
|
|
this._arrayProperty = arrayProperty; |
|
|
|
|
this.fixedItemHeight = fixedItemHeight; |
|
|
|
|
this.block = _block; |
|
|
|
|
|
|
|
|
|
list = new ReorderableList(arrayProperty.serializedObject, arrayProperty, true, true, false, false); |
|
|
|
|
list.drawHeaderCallback = DrawHeader; |
|
|
|
|
list.drawElementCallback = DrawItem; |
|
|
|
|
//list.elementHeightCallback = GetElementHeight; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//private float GetElementHeight(int index) |
|
|
|
|
//{ |
|
|
|
|
// return EditorGUI.GetPropertyHeight(this[index], null, true);// + EditorGUIUtility.singleLineHeight; |
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
private void DrawHeader(Rect rect) |
|
|
|
|
{ |
|
|
|
|
EditorGUI.LabelField(rect, new GUIContent("Commands")); |
|
|
|
@ -173,7 +182,8 @@ namespace Fungus.EditorUtils
|
|
|
|
|
// Command key and shift key is not pressed |
|
|
|
|
if (!EditorGUI.actionKey && !Event.current.shift) |
|
|
|
|
{ |
|
|
|
|
BlockEditor.actionList.Add ( delegate { |
|
|
|
|
BlockEditor.actionList.Add(delegate |
|
|
|
|
{ |
|
|
|
|
flowchart.SelectedCommands.Remove(command); |
|
|
|
|
flowchart.ClearSelectedCommands(); |
|
|
|
|
}); |
|
|
|
@ -182,7 +192,8 @@ namespace Fungus.EditorUtils
|
|
|
|
|
// Command key pressed |
|
|
|
|
if (EditorGUI.actionKey) |
|
|
|
|
{ |
|
|
|
|
BlockEditor.actionList.Add ( delegate { |
|
|
|
|
BlockEditor.actionList.Add(delegate |
|
|
|
|
{ |
|
|
|
|
flowchart.SelectedCommands.Remove(command); |
|
|
|
|
}); |
|
|
|
|
Event.current.Use(); |
|
|
|
@ -195,13 +206,15 @@ namespace Fungus.EditorUtils
|
|
|
|
|
// Left click and no command key |
|
|
|
|
if (!shift && !EditorGUI.actionKey && Event.current.button == 0) |
|
|
|
|
{ |
|
|
|
|
BlockEditor.actionList.Add ( delegate { |
|
|
|
|
BlockEditor.actionList.Add(delegate |
|
|
|
|
{ |
|
|
|
|
flowchart.ClearSelectedCommands(); |
|
|
|
|
}); |
|
|
|
|
Event.current.Use(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BlockEditor.actionList.Add ( delegate { |
|
|
|
|
BlockEditor.actionList.Add(delegate |
|
|
|
|
{ |
|
|
|
|
flowchart.AddSelectedCommand(command); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -210,7 +223,7 @@ namespace Fungus.EditorUtils
|
|
|
|
|
int lastSelectedIndex = -1; |
|
|
|
|
if (flowchart.SelectedCommands.Count > 0) |
|
|
|
|
{ |
|
|
|
|
if ( flowchart.SelectedBlock != null) |
|
|
|
|
if (flowchart.SelectedBlock != null) |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; i++) |
|
|
|
|
{ |
|
|
|
@ -224,7 +237,7 @@ namespace Fungus.EditorUtils
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i = flowchart.SelectedBlock.CommandList.Count - 1; i >=0; i--) |
|
|
|
|
for (int i = flowchart.SelectedBlock.CommandList.Count - 1; i >= 0; i--) |
|
|
|
|
{ |
|
|
|
|
Command commandInBlock = flowchart.SelectedBlock.CommandList[i]; |
|
|
|
|
foreach (Command selectedCommand in flowchart.SelectedCommands) |
|
|
|
@ -264,7 +277,8 @@ namespace Fungus.EditorUtils
|
|
|
|
|
for (int i = Math.Min(firstSelectedIndex, lastSelectedIndex); i < Math.Max(firstSelectedIndex, lastSelectedIndex); ++i) |
|
|
|
|
{ |
|
|
|
|
var selectedCommand = flowchart.SelectedBlock.CommandList[i]; |
|
|
|
|
BlockEditor.actionList.Add ( delegate { |
|
|
|
|
BlockEditor.actionList.Add(delegate |
|
|
|
|
{ |
|
|
|
|
flowchart.AddSelectedCommand(selectedCommand); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -367,13 +381,5 @@ namespace Fungus.EditorUtils
|
|
|
|
|
GUI.backgroundColor = Color.white; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual float GetItemHeight(int index) { |
|
|
|
|
return fixedItemHeight != 0f |
|
|
|
|
? fixedItemHeight |
|
|
|
|
: EditorGUI.GetPropertyHeight(this[index], GUIContent.none, false) |
|
|
|
|
; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|