Browse Source

Sequence node width can now be edited in inspector

master
chrisgregan 10 years ago
parent
commit
eaedbdadaa
  1. 5
      Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs
  2. 2
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs
  3. 14
      Assets/Fungus/FungusScript/Editor/SequenceEditor.cs
  4. 2
      Assets/Fungus/FungusScript/Scripts/Node.cs

5
Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs

@ -14,9 +14,8 @@ namespace Fungus
newFungusScriptGO.name = "FungusScript";
FungusScript fungusScript = newFungusScriptGO.AddComponent<FungusScript>();
Sequence sequence = Undo.AddComponent<Sequence>(newFungusScriptGO);
sequence.nodeRect.x += 50;
sequence.nodeRect.y += 50;
sequence.nodeRect.width = 240;
sequence.nodeRect.x += 60;
sequence.nodeRect.y += 60;
fungusScript.startSequence = sequence;
fungusScript.selectedSequence = sequence;
fungusScript.scrollPos = Vector2.zero;

2
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

@ -209,7 +209,6 @@ namespace Fungus
Rect windowRect = new Rect(sequence.nodeRect);
windowRect.x += fungusScript.scrollPos.x;
windowRect.y += fungusScript.scrollPos.y;
windowRect.width = 240;
GUILayout.Window(i, windowRect, DrawWindow, "", windowStyle);
@ -373,7 +372,6 @@ namespace Fungus
Undo.RegisterCreatedObjectUndo(newSequence, "New Sequence");
fungusScript.selectedSequence = newSequence;
fungusScript.ClearSelectedCommands();
newSequence.nodeRect.width = 240;
return newSequence;
}

14
Assets/Fungus/FungusScript/Editor/SequenceEditor.cs

@ -26,8 +26,18 @@ namespace Fungus
// We acquire the serialized properties in the draw methods instead of in OnEnable as otherwise
// deleting or renaming a command class would generate a bunch of null reference exceptions.
SerializedProperty sequenceNameProp = serializedObject.FindProperty("sequenceName");
EditorGUILayout.PropertyField(sequenceNameProp);
SerializedProperty nodeRectProp = serializedObject.FindProperty("nodeRect");
EditorGUI.BeginChangeCheck();
float width = EditorGUILayout.FloatField(new GUIContent("Node Width"), nodeRectProp.rectValue.width);
if (EditorGUI.EndChangeCheck())
{
Rect nodeRect = nodeRectProp.rectValue;
nodeRect.width = Mathf.Max(width, 100);
nodeRectProp.rectValue = nodeRect;
}
EditorGUILayout.Separator();
serializedObject.ApplyModifiedProperties();
@ -40,8 +50,6 @@ namespace Fungus
Sequence sequence = target as Sequence;
UpdateIndentLevels(sequence);
sequence.nodeRect.width = 240;
SerializedProperty commandListProperty = serializedObject.FindProperty("commandList");
ReorderableListGUI.Title(sequence.sequenceName);

2
Assets/Fungus/FungusScript/Scripts/Node.cs

@ -6,7 +6,7 @@ namespace Fungus
public class Node : MonoBehaviour
{
public Rect nodeRect = new Rect(10, 10, 100, 20);
public Rect nodeRect = new Rect(0, 0, 240, 20);
}
}
Loading…
Cancel
Save