Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update ();

            EditorGUILayout.PropertyField (OnStartSerializedProperty, new GUIContent("OnStart"));
            EditorGUILayout.PropertyField (OnEndSerializedProperty, new GUIContent("OnEnd"));

            EditorGUILayout.PropertyField (wrapSerializedProperty, new GUIContent("Wrap Mode"));
            EditorGUILayout.PropertyField (playOnStartSerializedProperty, new GUIContent("Play On Start"));

            SequenceNode selectedNode=selectedNodeSerializedProperty.objectReferenceValue as SequenceNode;
            serializedObject.ApplyModifiedProperties ();
            Sequence sequence = target as Sequence;

            EditorGUILayout.BeginHorizontal ();
            if (GUILayout.Button ("Play")) {
                sequence.PlayAt();

            }

            if (GUILayout.Button ("Stop Forward")) {
                sequence.Stop(true);
            }

            if (GUILayout.Button ("Stop Reset")) {
                //sequence.Stop(false);
                Debug.Log("Not yet tested, not finished");
            }

            if (GUILayout.Button ("Pause")) {
                //sequence.Pause();
                Debug.Log("Not yet tested, not finished");
            }
            if (GUILayout.Button ("UnPause")) {
                Debug.Log("Not yet tested, not finished");
                //sequence.UnPause();
            }
            if (GUILayout.Button ("Restart")) {
                //sequence.Restart();
                Debug.Log("Not yet tested, not finished");
            }
            if (GUILayout.Button ("Open Editor")) {
                SequenceEditorWindow.ShowWindow();
            }

            EditorGUILayout.EndHorizontal ();

            if (selectedNode != null){

                if(selectedNode!=selectedNodePrev)
                                  	 nodeEditor=Editor.CreateEditor (selectedNode, typeof(SequenceNodeEditor)) as SequenceNodeEditor;

                selectedNodePrev=selectedNode;

                nodeEditor.OnInspectorGUI();
            }
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            //serializedObject.Update ();

            sequence = sequenceSerialziedProperty.objectReferenceValue as Sequence;

            EditorGUI.BeginChangeCheck();

            if (sequence != null)
            {
                wrapSerializedProperty.enumValueIndex = (int)sequence.wrap;
                EditorGUILayout.PropertyField(wrapSerializedProperty, wrapCurrentGUIContent);
                sequence.wrap = (Sequence.SequenceWrap)wrapSerializedProperty.enumValueIndex;
            }
            EditorGUILayout.PropertyField(playOnStartSerializedProperty, playOnStartGUIContent);



            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PropertyField(sequenceSerialziedProperty, sequenceGUIContent);

            if (GUILayout.Button(cloneSequenceGUIContent))
            {
                if (sequence != null)
                {
                    Sequence sequenceNew = ScriptableObject.CreateInstance <Sequence>();



                    EditorUtilityEx.CreateAssetFromInstance(sequenceNew);

                    foreach (SequenceChannel channel in sequence.channels)
                    {
                        SequenceChannel channelClone = UnityEngine.Object.Instantiate <SequenceChannel>(channel);
                        channelClone.nodes.Clear();
                        sequenceNew.channels.Add(channelClone);
                        channelClone.sequence = sequenceNew;
                        AssetDatabase.AddObjectToAsset(channelClone, sequenceNew);

                        foreach (SequenceNode node in channel.nodes)
                        {
                            SequenceNode nodeClone = UnityEngine.Object.Instantiate <SequenceNode>(node);
                            nodeClone.channel = channelClone;
                            channelClone.nodes.Add(nodeClone);
                            AssetDatabase.AddObjectToAsset(nodeClone, channelClone);

                            EditorClipBinding clipBindingClone = UnityEngine.Object.Instantiate <EditorClipBinding>(node.clipBinding);
                            nodeClone.clipBinding = clipBindingClone;
                            AssetDatabase.AddObjectToAsset(clipBindingClone, nodeClone);
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();



            if (sequence != null)
            {
                timeCurrentSerializedProperty.floatValue = (float)sequence.timeCurrent;
                timeCurrentSerializedProperty.serializedObject.ApplyModifiedProperties();

                EditorGUILayout.Slider(timeCurrentSerializedProperty, (float)sequence.timeStart, (float)sequence.timeEnd);

                sequence.timeCurrent = timeCurrentSerializedProperty.floatValue;



                EditorGUILayout.BeginHorizontal();

                if (GUILayout.Button("Goto"))
                {
                    sequence.GoTo(timeCurrentSerializedProperty.floatValue);
                }


                if (GUILayout.Button(!Application.isPlaying ? (sequence.isPlaying ? "Pause" : "Play Forward") : "Play Forward"))
                {
                    if (Application.isPlaying)
                    {
                        sequence.Play(sequence.timeCurrent);
                    }
                    else
                    {
                        SequenceEditorWindow.Play();
                    }
                }

                if (GUILayout.Button("Play Backward"))
                {
                    if (Application.isPlaying)
                    {
                        sequence.Play(sequence.timeCurrent, false);
                    }
                    else
                    {
                        SequenceEditorWindow.Play(false);
                    }
                }

                if (GUILayout.Button("Stop"))
                {
                    if (Application.isPlaying)
                    {
                        sequence.Stop();
                    }
                    else
                    {
                        SequenceEditorWindow.Stop();
                    }
                }

                if (Application.isPlaying)
                {
                    if (GUILayout.Button("Pause"))
                    {
                        Debug.LogWarning("Not yet tested, not finished");

                        sequence.Pause();
                    }
                }

                if (Application.isPlaying)
                {
                    if (GUILayout.Button("UnPause"))
                    {
                        Debug.LogWarning("Not yet tested, not finished");
                        sequence.UnPause();
                    }
                }

                if (!Application.isPlaying)
                {
                    if (GUILayout.Button("Open Editor"))
                    {
                        SequenceEditorWindow.ShowWindow();
                    }
                }

                EditorGUILayout.EndHorizontal();


                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();

                    SequenceEditorWindow.window.Repaint();
                }

                //EditorUtilityEx.GetDrawer(typeof(UnityEngine.Events.UnityEventBase)).


                ///// DRAW SELECTED NODE (inside SequenceEditor) ////////
                SequenceNode selectedNode = sequence.nodeSelected;
                if (selectedNode != null)
                {
                    if (selectedNode != selectedNodePrev)
                    {
                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Selected Node");
                        EditorGUILayout.Space();
                        nodeEditor = Editor.CreateEditor(selectedNode, typeof(SequenceNodeEditor)) as SequenceNodeEditor;
                        EditorGUILayout.Space();
                    }


                    nodeEditor.OnInspectorGUI();
                }
                else
                {
                    EditorGUILayout.LabelField("No Node selected");
                }

                selectedNodePrev = selectedNode;
            }
        }