diff --git a/Assets/Fungus/Editor/FungusEditorWindow.cs b/Assets/Fungus/Editor/FungusEditorWindow.cs index 5a90622a..67946076 100755 --- a/Assets/Fungus/Editor/FungusEditorWindow.cs +++ b/Assets/Fungus/Editor/FungusEditorWindow.cs @@ -7,9 +7,11 @@ using Fungus; public class FungusEditorWindow : EditorWindow { + [System.NonSerialized] + public Vector2 scrollPos; // ScrollViews use a Vector2 to track the state of each scroll bar + private List windowSequenceMap = new List(); - private Vector2 scrollPos; // ScrollViews use a Vector2 to track the state of each scroll bar - + private GameObject cachedSelection; [MenuItem("Window/Fungus Editor")] @@ -63,6 +65,7 @@ public class FungusEditorWindow : EditorWindow Sequence[] sequences = sequenceController.GetComponentsInChildren(); Rect scrollViewRect = new Rect(); + foreach (Sequence s in sequences) { scrollViewRect.xMin = Mathf.Min(scrollViewRect.xMin, s.nodeRect.xMin); diff --git a/Assets/Fungus/Editor/SequenceControllerEditor.cs b/Assets/Fungus/Editor/SequenceControllerEditor.cs index 0cd412dc..397cd9c9 100644 --- a/Assets/Fungus/Editor/SequenceControllerEditor.cs +++ b/Assets/Fungus/Editor/SequenceControllerEditor.cs @@ -28,6 +28,19 @@ public class SequenceControllerEditor : Editor { EditorWindow.GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor"); } + + if (GUILayout.Button("New Sequence")) + { + GameObject go = new GameObject("Sequence"); + go.transform.parent = t.transform; + Sequence s = go.AddComponent(); + FungusEditorWindow fungusEditorWindow = EditorWindow.GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor") as FungusEditorWindow; + s.nodeRect.x = fungusEditorWindow.scrollPos.x; + s.nodeRect.y = fungusEditorWindow.scrollPos.y; + Undo.RegisterCreatedObjectUndo(go, "Sequence"); + Selection.activeGameObject = go; + } + GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } diff --git a/Assets/Fungus/Tests/Sequence/SequenceTest.unity b/Assets/Fungus/Tests/Sequence/SequenceTest.unity index bc968193..bee63194 100644 Binary files a/Assets/Fungus/Tests/Sequence/SequenceTest.unity and b/Assets/Fungus/Tests/Sequence/SequenceTest.unity differ