public static Sequence CreateSequence(FungusScript fungusScript, Vector2 position)
        {
            Sequence newSequence = fungusScript.CreateSequence(position);

            Undo.RegisterCreatedObjectUndo(newSequence, "New Sequence");
            ShowSequenceInspector(fungusScript);
            fungusScript.selectedSequence = newSequence;
            fungusScript.ClearSelectedCommands();

            return(newSequence);
        }
示例#2
0
        void CreateSequenceCallback(object item)
        {
            FungusScript fungusScript = GetFungusScript();

            if (fungusScript != null)
            {
                Vector2 position = (Vector2)item;
                position -= fungusScript.scriptScrollPos;
                Sequence newSequence = fungusScript.CreateSequence(position);
                Undo.RegisterCreatedObjectUndo(newSequence, "New Sequence");
                fungusScript.selectedSequence = newSequence;
            }
        }
示例#3
0
		void DrawSequenceView(FungusScript fungusScript)
		{
			GUILayout.Space(5);

			fungusScript.commandScrollPos = GUILayout.BeginScrollView(fungusScript.commandScrollPos);

			EditorGUILayout.BeginVertical();

			GUILayout.Box("Sequence", GUILayout.ExpandWidth(true));

			GUILayout.BeginHorizontal();
			
			if (fungusScript.selectedSequence == null)
			{
				GUILayout.FlexibleSpace();
			}
			
			if (GUILayout.Button(fungusScript.selectedSequence == null ? "Create Sequence" : "Create", 
			                     fungusScript.selectedSequence == null ?  EditorStyles.miniButton : EditorStyles.miniButtonLeft))
			{
				Sequence newSequence = fungusScript.CreateSequence(fungusScript.scriptScrollPos);
				Undo.RegisterCreatedObjectUndo(newSequence, "New Sequence");
				fungusScript.selectedSequence = newSequence;
				fungusScript.selectedCommand = null;
			}
			
			if (fungusScript.selectedSequence == null)
			{
				GUILayout.FlexibleSpace();
			}
			
			if (fungusScript.selectedSequence != null)
			{
				if (GUILayout.Button("Delete", EditorStyles.miniButtonMid))
				{
					Undo.DestroyObjectImmediate(fungusScript.selectedSequence.gameObject);
					fungusScript.selectedSequence = null;
					fungusScript.selectedCommand = null;
				}
				if (GUILayout.Button("Duplicate", EditorStyles.miniButtonRight))
				{
					GameObject copy = GameObject.Instantiate(fungusScript.selectedSequence.gameObject) as GameObject;
					copy.transform.parent = fungusScript.transform;
					copy.transform.hideFlags = HideFlags.HideInHierarchy;
					copy.name = fungusScript.selectedSequence.name;
					
					Sequence sequenceCopy = copy.GetComponent<Sequence>();
					sequenceCopy.nodeRect.x += sequenceCopy.nodeRect.width + 10;
					
					Undo.RegisterCreatedObjectUndo(copy, "Duplicate Sequence");
					fungusScript.selectedSequence = sequenceCopy;
					fungusScript.selectedCommand = null;
				}
			}
			
			GUILayout.EndHorizontal();

			if (fungusScript.selectedSequence != null)
			{
				EditorGUILayout.Separator();

				SequenceEditor sequenceEditor = Editor.CreateEditor(fungusScript.selectedSequence) as SequenceEditor;
				sequenceEditor.DrawSequenceGUI(fungusScript);
				DestroyImmediate(sequenceEditor);

				GUILayout.FlexibleSpace();
			}

			EditorGUILayout.EndVertical();

			GUILayout.EndScrollView();
		}
示例#4
0
        void DrawSequenceView(FungusScript fungusScript)
        {
            GUILayout.Space(5);

            fungusScript.commandScrollPos = GUILayout.BeginScrollView(fungusScript.commandScrollPos);

            EditorGUILayout.BeginVertical();

            GUILayout.Box("Sequence", GUILayout.ExpandWidth(true));

            GUILayout.BeginHorizontal();

            if (fungusScript.selectedSequence == null)
            {
                GUILayout.FlexibleSpace();
            }

            if (GUILayout.Button(fungusScript.selectedSequence == null ? "Create Sequence" : "Create",
                                 fungusScript.selectedSequence == null ?  EditorStyles.miniButton : EditorStyles.miniButtonLeft))
            {
                Sequence newSequence = fungusScript.CreateSequence(fungusScript.scriptScrollPos);
                Undo.RegisterCreatedObjectUndo(newSequence, "New Sequence");
                fungusScript.selectedSequence = newSequence;
                fungusScript.selectedCommand  = null;
            }

            if (fungusScript.selectedSequence == null)
            {
                GUILayout.FlexibleSpace();
            }

            if (fungusScript.selectedSequence != null)
            {
                if (GUILayout.Button("Delete", EditorStyles.miniButtonMid))
                {
                    Undo.DestroyObjectImmediate(fungusScript.selectedSequence.gameObject);
                    fungusScript.selectedSequence = null;
                    fungusScript.selectedCommand  = null;
                }
                if (GUILayout.Button("Duplicate", EditorStyles.miniButtonRight))
                {
                    GameObject copy = GameObject.Instantiate(fungusScript.selectedSequence.gameObject) as GameObject;
                    copy.transform.parent    = fungusScript.transform;
                    copy.transform.hideFlags = HideFlags.HideInHierarchy;
                    copy.name = fungusScript.selectedSequence.name;

                    Sequence sequenceCopy = copy.GetComponent <Sequence>();
                    sequenceCopy.nodeRect.x += sequenceCopy.nodeRect.width + 10;

                    Undo.RegisterCreatedObjectUndo(copy, "Duplicate Sequence");
                    fungusScript.selectedSequence = sequenceCopy;
                    fungusScript.selectedCommand  = null;
                }
            }

            GUILayout.EndHorizontal();

            if (fungusScript.selectedSequence != null)
            {
                EditorGUILayout.Separator();

                SequenceEditor sequenceEditor = Editor.CreateEditor(fungusScript.selectedSequence) as SequenceEditor;
                sequenceEditor.DrawSequenceGUI(fungusScript);
                DestroyImmediate(sequenceEditor);

                GUILayout.FlexibleSpace();
            }

            EditorGUILayout.EndVertical();

            GUILayout.EndScrollView();
        }