예제 #1
0
        internal void OnGUI(ImageSequencer editor)
        {
            OnGUI();

            // Processor extra info
            GUI.BeginGroup(displayRect);
            if (editor.currentProcessingNode != null && editor.currentProcessingNode.Enabled && m_bShowExtraInfo && editor.sidePanelViewMode == ImageSequencer.SidePanelMode.Processors)
            {
                editor.currentProcessingNode.OnCanvasGUI(this);
            }
            GUI.EndGroup();

            // Everytime text
            string procName = (editor.sidePanelViewMode == ImageSequencer.SidePanelMode.Export) ? "Export" : (sequence.processingNode == null ? "Input Frames" : sequence.processingNode.ToString());

            GUI.Label(new RectOffset(24, 24, 24, 24).Remove(displayRect), procName, styles.largeLabel);
            GUI.Label(new RectOffset(24, 24, 64, 24).Remove(displayRect), GetDebugInfoString(), styles.label);
            //EditorGUI.DrawRect(m_Rect, Color.red);

            // Play Controls
            if (sequence != null && sequence.length > 1)
            {
                DrawSequenceControls(displayRect, editor);
            }

            if (m_IsPlaying)
            {
                UpdatePlay();
            }
        }
예제 #2
0
        internal ImageSequencerCanvas(Rect displayRect, ImageSequencer editorWindow)
            : base(displayRect)
        {
            m_ImageSequencerWindow = editorWindow;

            m_IsScrobbing      = false;
            m_PlayControlsRect = new Rect(16, 16, 420, 26);
        }
        public static bool OpenImageSequenceAsset(int instanceID, int line)
        {
            ImageSequence asset = EditorUtility.InstanceIDToObject(instanceID) as ImageSequence;

            if (asset != null) // We opened an image sequence asset, open the editor.
            {
                ImageSequencer.OpenEditor();
                ImageSequencer window = EditorWindow.GetWindow <ImageSequencer>();
                window.Focus();
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
 public CanvasConfigPopupWindowContent(ImageSequencer window)
 {
     m_Window = window;
 }
예제 #5
0
 public ProcessingNodeStack(ProcessingFrameSequence inputSequence, ImageSequencer imageSequencer)
 {
     m_InputSequence   = inputSequence;
     m_ProcessingNodes = new List <ProcessingNode>();
     m_ImageSequencer  = imageSequencer;
 }
예제 #6
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            m_RequireConstantRepaint = false;

            using (new EditorGUILayout.VerticalScope())
            {
                if (GUILayout.Button(VFXToolboxGUIUtility.Get("Edit Sequence"), GUILayout.Height(40)))
                {
                    ImageSequencer toolbox = EditorWindow.GetWindow <ImageSequencer>();
                    toolbox.LoadAsset((ImageSequence)Selection.activeObject);
                }

                VFXToolboxGUIUtility.ToggleableHeader(true, false, "Input Frames");
                {
                    var inputFrames     = serializedObject.FindProperty("inputFrameGUIDs");
                    int inputFrameCount = inputFrames.arraySize;
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Input sequence contains " + inputFrameCount + " frame(s).");
                        GUILayout.FlexibleSpace();
                        m_PreviewInput = GUILayout.Toggle(m_PreviewInput, VFXToolboxGUIUtility.Get("Preview"), EditorStyles.miniButton);
                    }

                    if (inputFrameCount > 0 && m_PreviewInput)
                    {
                        int index;

                        if (inputFrameCount > 1)
                        {
                            m_RequireConstantRepaint = true;
                            float time = (float)EditorApplication.timeSinceStartup;
                            index = (int)Mathf.Floor((time * 30) % inputFrameCount);
                        }
                        else
                        {
                            index = 0;
                        }

                        var    frame   = inputFrames.GetArrayElementAtIndex(index);
                        string guid    = frame.stringValue;
                        var    texture = AssetDatabase.LoadAssetAtPath <Texture2D>(AssetDatabase.GUIDToAssetPath(guid));
                        DrawAnimatedPreviewLayout(texture, ((float)index / inputFrameCount));
                    }
                    else
                    {
                        m_PreviewInput = false;
                    }
                }

                GUILayout.Space(24);
                VFXToolboxGUIUtility.ToggleableHeader(true, false, "Processors");
                {
                    var processors      = serializedObject.FindProperty("processorInfos");
                    int processorsCount = processors.arraySize;
                    EditorGUILayout.LabelField("Asset contains " + processorsCount + " Processor (s).");
                    EditorGUI.indentLevel++;
                    for (int i = 0; i < processorsCount; i++)
                    {
                        var item = processors.GetArrayElementAtIndex(i).objectReferenceValue as ProcessorInfo;
                        EditorGUILayout.LabelField("#" + i + " - " + item.Settings.label + (item.Enabled ? "" : " (Disabled)"));
                    }
                    EditorGUI.indentLevel--;
                }


                GUILayout.Space(24);
                VFXToolboxGUIUtility.ToggleableHeader(true, false, "Export Settings");

                var exportSettings = serializedObject.FindProperty("exportSettings");

                string fileName   = exportSettings.FindPropertyRelative("fileName").stringValue;
                var    mode       = (ImageSequence.ExportMode)exportSettings.FindPropertyRelative("exportMode").enumValueIndex;
                var    frameCount = exportSettings.FindPropertyRelative("frameCount");

                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.EnumPopup(VFXToolboxGUIUtility.Get("Export Format"), mode);
                EditorGUI.EndDisabledGroup();
                if (fileName != "")
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.TextField("Export Path", fileName);
                    EditorGUI.EndDisabledGroup();
                }
                else
                {
                    EditorGUILayout.HelpBox("This asset has not yet been exported. Please open editor and export it to generate a sequence.", MessageType.None);
                }
            }
        }
예제 #7
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            m_RequireConstantRepaint = false;

            using (new EditorGUILayout.VerticalScope())
            {
                if (GUILayout.Button(VFXToolboxGUIUtility.Get("Edit Sequence"), GUILayout.Height(40)))
                {
                    ImageSequencer toolbox = EditorWindow.GetWindow <ImageSequencer>();
                    toolbox.LoadAsset((ImageSequence)Selection.activeObject);
                }

                VFXToolboxGUIUtility.ToggleableHeader(true, false, "Input Frames");
                {
                    var inputFrames     = serializedObject.FindProperty("inputFrameGUIDs");
                    int inputFrameCount = inputFrames.arraySize;
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Input sequence contains " + inputFrameCount + " frame(s).");
                        GUILayout.FlexibleSpace();
                        m_PreviewInput = GUILayout.Toggle(m_PreviewInput, VFXToolboxGUIUtility.Get("Preview"), EditorStyles.miniButton);
                    }

                    if (inputFrameCount > 0 && m_PreviewInput)
                    {
                        int index;

                        if (inputFrameCount > 1)
                        {
                            m_RequireConstantRepaint = true;
                            float time = (float)EditorApplication.timeSinceStartup;
                            index = (int)Mathf.Floor((time * 30) % inputFrameCount);
                        }
                        else
                        {
                            index = 0;
                        }

                        var    frame   = inputFrames.GetArrayElementAtIndex(index);
                        string guid    = frame.stringValue;
                        var    texture = AssetDatabase.LoadAssetAtPath <Texture2D>(AssetDatabase.GUIDToAssetPath(guid));
                        DrawAnimatedPreviewLayout(texture, ((float)index / inputFrameCount));
                    }
                    else
                    {
                        m_PreviewInput = false;
                    }
                }


                GUILayout.Space(24);
                VFXToolboxGUIUtility.ToggleableHeader(true, false, "Processors");
                {
                    var processors      = serializedObject.FindProperty("processorInfos");
                    int processorsCount = processors.arraySize;
                    EditorGUILayout.LabelField("Asset contains " + processorsCount + " Processor (s).");
                    EditorGUI.indentLevel++;
                    for (int i = 0; i < processorsCount; i++)
                    {
                        var item = processors.GetArrayElementAtIndex(i).objectReferenceValue as ProcessorInfo;
                        EditorGUILayout.LabelField("#" + i + " - " + item.Settings.label + (item.Enabled?"":" (Disabled)"));
                    }
                    EditorGUI.indentLevel--;
                }


                GUILayout.Space(24);
                VFXToolboxGUIUtility.ToggleableHeader(true, false, "Export Settings");

                var exportSettings = serializedObject.FindProperty("exportSettings");

                string fileName   = exportSettings.FindPropertyRelative("fileName").stringValue;
                var    mode       = (ImageSequence.ExportMode)exportSettings.FindPropertyRelative("exportMode").enumValueIndex;
                var    frameCount = exportSettings.FindPropertyRelative("frameCount");

                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.EnumPopup(VFXToolboxGUIUtility.Get("Export Format"), mode);
                EditorGUI.EndDisabledGroup();

                if (fileName != "")
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.TextField("Exporting to ", fileName);
                    EditorGUI.EndDisabledGroup();

                    Rect r = GUILayoutUtility.GetLastRect();
                    r.width += EditorGUIUtility.fieldWidth;
                    if (Event.current.rawType == EventType.MouseDown && r.Contains(Event.current.mousePosition))
                    {
                        ImageSequencer.PingOutputTexture(fileName);
                    }

                    string dir  = System.IO.Path.GetDirectoryName(fileName);
                    string file = System.IO.Path.GetFileNameWithoutExtension(fileName);

                    string[] assets;

                    if (!fileName.StartsWith("Assets/"))
                    {
                        EditorGUILayout.HelpBox("The output sequence has been exported outside the project, preview will be unavailable", MessageType.Warning);
                        return;
                    }

                    if (fileName.Contains("#"))
                    {
                        if (System.IO.Directory.Exists(dir))
                        {
                            string[] guids = AssetDatabase.FindAssets(file.Replace('#', '*'), new string[] { dir });
                            assets = new string[guids.Length];
                            for (int i = 0; i < guids.Length; i++)
                            {
                                assets[i] = AssetDatabase.GUIDToAssetPath(guids[i]);
                            }
                        }
                        else
                        {
                            assets = new string[] { }
                        };
                    }
                    else
                    {
                        assets = new string[] { fileName };
                    }

                    int outputFrameCount;
                    if (frameCount.intValue == assets.Length)
                    {
                        outputFrameCount = frameCount.intValue;
                    }
                    else
                    {
                        outputFrameCount = 0; // Something went wrong
                    }
                    if (outputFrameCount > 0)
                    {
                        if (outputFrameCount > 1)
                        {
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                GUILayout.Label("Output sequence contains " + assets.Length + " frame(s).");
                                GUILayout.FlexibleSpace();
                                m_PreviewOutput = GUILayout.Toggle(m_PreviewOutput, VFXToolboxGUIUtility.Get("Preview"), EditorStyles.miniButton);
                            }

                            if (m_PreviewOutput)
                            {
                                m_RequireConstantRepaint = true;
                                float time    = (float)EditorApplication.timeSinceStartup;
                                int   index   = (int)Mathf.Floor((time * 30) % outputFrameCount);
                                var   texture = AssetDatabase.LoadAssetAtPath <Texture2D>(assets[index]);
                                DrawAnimatedPreviewLayout(texture, ((float)index / outputFrameCount));
                            }
                            else
                            {
                                m_PreviewOutput = false;
                            }
                        }
                        else // Only one frame
                        {
                            var texture = AssetDatabase.LoadAssetAtPath <Texture2D>(assets[0]);
                            if (texture != null)
                            {
                                DrawAnimatedPreviewLayout(texture, 0.0f);
                            }
                            else
                            {
                                EditorGUILayout.HelpBox("Output Texture could not be loaded, maybe the file was deleted. Please export again using the editor", MessageType.Error);
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("The output sequence does not match the number of files on disk, you probably need to export your sequence again", MessageType.Warning);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("This asset has not yet been exported. Please open editor and export it to generate a sequence.", MessageType.None);
                }
            }
        }
예제 #8
0
        internal void DrawSequenceControls(Rect ViewportArea, ImageSequencer editor)
        {
            m_PlayControlsRect = new Rect(ViewportArea.x, (ViewportArea.y + ViewportArea.height), ViewportArea.width, 100);

            using (new GUILayout.AreaScope(m_PlayControlsRect, GUIContent.none, ImageSequencer.styles.playbackControlWindow))
            {
                Rect area = new Rect(16, 16, m_PlayControlsRect.width - 32, m_PlayControlsRect.height - 32);
                //GUILayout.BeginArea(area);
                using (new GUILayout.VerticalScope())
                {
                    // TRACKBAR
                    int count = sequence.length;

                    GUILayout.Space(16); // Reserve Layout for labels
                    Rect bar_rect = GUILayoutUtility.GetRect(area.width, 16);

                    EditorGUIUtility.AddCursorRect(bar_rect, MouseCursor.ResizeHorizontal);
                    if (Event.current.type == EventType.MouseDown && bar_rect.Contains(Event.current.mousePosition))
                    {
                        m_IsScrobbing = true;
                    }

                    if (Event.current.type == EventType.MouseUp || Event.current.rawType == EventType.MouseUp)
                    {
                        m_IsScrobbing = false;
                    }

                    if (m_IsScrobbing && (Event.current.type == EventType.MouseDrag || Event.current.type == EventType.MouseDown))
                    {
                        float pos   = (Event.current.mousePosition.x - bar_rect.x) / bar_rect.width;
                        int   frame = (int)Mathf.Round(pos * numFrames);
                        if (frame != currentFrameIndex)
                        {
                            currentFrameIndex = frame;
                            Invalidate(true);
                        }
                    }

                    EditorGUI.DrawRect(bar_rect, ImageSequencer.styles.CookBarDirty);

                    float width = bar_rect.width / count;

                    Rect textpos;

                    for (int i = 0; i < count; i++)
                    {
                        if (!sequence.frames[i].dirty)
                        {
                            Rect cell = new Rect(bar_rect.x + i * width, bar_rect.y, width, bar_rect.height);
                            EditorGUI.DrawRect(cell, ImageSequencer.styles.CookBarCooked);
                        }

                        if (i == currentFrameIndex)
                        {
                            Rect cursor = new Rect(bar_rect.x + i * width, bar_rect.y, width, bar_rect.height);
                            EditorGUI.DrawRect(cursor, new Color(1.0f, 1.0f, 1.0f, 0.5f));
                        }

                        // Labels : Every multiple of 10 based on homemade formula
                        int step = 10 * (int)Mathf.Max(1, Mathf.Floor(8 * (float)count / bar_rect.width));

                        if (((i + 1) % step) == 0)
                        {
                            textpos = new Rect(bar_rect.x + i * width, bar_rect.y - 16, 32, 16);
                            GUI.Label(textpos, (i + 1).ToString(), EditorStyles.largeLabel);
                            Rect cursor = new Rect(bar_rect.x + i * width, bar_rect.y, 1, bar_rect.height);
                            EditorGUI.DrawRect(cursor, new Color(1.0f, 1.0f, 1.0f, 0.2f));
                        }
                    }

                    // Labels : First
                    textpos = new Rect(bar_rect.x, bar_rect.y - 16, 32, 16);
                    GUI.Label(textpos, VFXToolboxGUIUtility.Get("1"), EditorStyles.largeLabel);
                    GUILayout.Space(16);

                    // PLAY CONTROLS

                    bool lastplay;
                    using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
                    {
                        lastplay = m_IsPlaying;
                        if (GUILayout.Button(ImageSequencer.styles.iconFirst, VFXToolboxStyles.toolbarButton, GUILayout.Width(32)))
                        {
                            FirstFrame();
                        }

                        if (GUILayout.Button(ImageSequencer.styles.iconBack, VFXToolboxStyles.toolbarButton, GUILayout.Width(24)))
                        {
                            PreviousFrame();
                        }

                        bool playing = GUILayout.Toggle(m_IsPlaying, ImageSequencer.styles.iconPlay, VFXToolboxStyles.toolbarButton, GUILayout.Width(24));
                        if (m_IsPlaying != playing)
                        {
                            TogglePlaySequence();
                        }

                        if (GUILayout.Button(ImageSequencer.styles.iconForward, VFXToolboxStyles.toolbarButton, GUILayout.Width(24)))
                        {
                            NextFrame();
                        }

                        if (GUILayout.Button(ImageSequencer.styles.iconLast, VFXToolboxStyles.toolbarButton, GUILayout.Width(32)))
                        {
                            LastFrame();
                        }

                        if (lastplay != m_IsPlaying)
                        {
                            m_EditorTime = EditorApplication.timeSinceStartup;
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.Label(VFXToolboxGUIUtility.GetTextAndIcon("Frame : ", "Profiler.Record"), VFXToolboxStyles.toolbarButton);
                        m_CurrentFrame = Mathf.Clamp(EditorGUILayout.IntField(m_CurrentFrame + 1, VFXToolboxStyles.toolbarTextField, GUILayout.Width(42)) - 1, 0, numFrames - 1);
                        GUILayout.Label(" on " + numFrames + " ( TCR : " + GetTCR(m_CurrentFrame, (int)m_PlayFramerate) + " ) ", VFXToolboxStyles.toolbarButton);
                        GUILayout.FlexibleSpace();
                        ShowFrameratePopup();
                    }
                }
                //GUILayout.EndArea();
            }
        }
예제 #9
0
 private void OnEnable()
 {
     ImageSequencer.CleanupAsset(this);
 }