Exemplo n.º 1
0
//----------------------------------------------------------------------------------------------------------------------
        public override void OnInspectorGUI()
        {
            //View resolution
            Vector2 res = ViewEditorUtility.GetMainGameViewSize();

            EditorGUILayout.LabelField("Resolution (Modify GameView size to change)");
            ++EditorGUI.indentLevel;
            EditorGUILayout.LabelField("Width", res.x.ToString(CultureInfo.InvariantCulture));
            EditorGUILayout.LabelField("Height", res.y.ToString(CultureInfo.InvariantCulture));
            --EditorGUI.indentLevel;
            EditorGUILayout.Space(15f);

            //Check if the asset is actually inspected
            if (null != TimelineEditor.selectedClip && TimelineEditor.selectedClip.asset != m_asset)
            {
                return;
            }

            ValidateAssetFolder();

            string prevFolder = m_asset.GetFolder();

            string newFolder = EditorGUIDrawerUtility.DrawFolderSelectorGUI("Cache Output Folder", "Select Folder",
                                                                            prevFolder, null
                                                                            );

            newFolder = AssetUtility.NormalizeAssetPath(newFolder);

            if (newFolder != prevFolder)
            {
                Undo.RecordObject(m_asset, "Change Output Folder");
                m_asset.SetFolder(AssetUtility.NormalizeAssetPath(newFolder));
                GUIUtility.ExitGUI();
            }

            //Output Format
            EditorGUIDrawerUtility.DrawUndoableGUI(m_asset, "RenderCache Output Format",
                                                   /*guiFunc=*/ () => (RenderCacheOutputFormat)EditorGUILayout.EnumPopup("Output Format:", m_asset.GetOutputFormat()),
                                                   /*updateFunc=*/ (RenderCacheOutputFormat newOutputFormat) => { m_asset.SetOutputFormat(newOutputFormat); }
                                                   );

            RenderCacheClipData clipData = m_asset.GetBoundClipData();

            if (null == clipData)
            {
                return;
            }

            GUILayout.Space(15);

            //Capture Selected Frames
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                DrawCaptureSelectedFramesGUI(TimelineEditor.selectedClip, clipData);
                DrawLockFramesGUI(TimelineEditor.selectedClip, clipData);
            }

            GUILayout.Space(15);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                EditorGUILayout.LabelField("Background Colors");
                ++EditorGUI.indentLevel;

                RenderCachePlayableAssetEditorConfig editorConfig = m_asset.GetEditorConfig();

                EditorGUIDrawerUtility.DrawUndoableGUI(m_asset, "Change Update BG Color",
                                                       /*guiFunc=*/ () => EditorGUILayout.ColorField("In Game Window (Update)", editorConfig.GetUpdateBGColor()),
                                                       /*updateFunc=*/ (Color newColor) => { editorConfig.SetUpdateBGColor(newColor); }
                                                       );

                EditorGUIDrawerUtility.DrawUndoableGUI(m_asset, "Change Timeline BG Color",
                                                       /*guiFunc=*/ () => EditorGUILayout.ColorField("In Timeline Window", m_asset.GetTimelineBGColor()),
                                                       /*updateFunc=*/ (Color newColor) => { m_asset.SetTimelineBGColor(newColor); }
                                                       );

                --EditorGUI.indentLevel;
                GUILayout.Space(5);
            }
            GUILayout.Space(15);
            DrawUpdateRenderCacheGUI();
        }
Exemplo n.º 2
0
//----------------------------------------------------------------------------------------------------------------------

        private void DrawUpdateRenderCacheGUI()
        {
            RenderCacheClipData clipData = m_asset.GetBoundClipData();

            Assert.IsNotNull(clipData);
            if (clipData.GetOwner().GetParentTrack().IsNullRef())
            {
                return;
            }

            ShortcutBinding updateRenderCacheShortcut
                = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_UPDATE_RENDER_CACHE);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                RenderCachePlayableAssetEditorConfig editorConfig = m_asset.GetEditorConfig();

                EditorGUI.BeginChangeCheck();

                bool captureAllFrames = EditorGUILayout.Toggle("Capture All Frames", editorConfig.GetCaptureAllFrames());
                EditorGUI.BeginDisabledGroup(captureAllFrames);
                ++EditorGUI.indentLevel;

                int captureStartFrame = Math.Max(0, editorConfig.GetCaptureStartFrame());
                int captureEndFrame   = editorConfig.GetCaptureEndFrame();
                if (captureEndFrame < 0)
                {
                    captureEndFrame = TimelineUtility.CalculateNumFrames(TimelineEditor.selectedClip);
                }

                captureStartFrame = EditorGUILayout.IntField("From", captureStartFrame);
                captureEndFrame   = EditorGUILayout.IntField("To", captureEndFrame);

                --EditorGUI.indentLevel;
                EditorGUI.EndDisabledGroup();

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_asset, "Change Frames to Capture");
                    editorConfig.SetCaptureAllFrames(captureAllFrames);
                    editorConfig.SetCaptureStartFrame(captureStartFrame);
                    editorConfig.SetCaptureEndFrame(captureEndFrame);
                }


                GUILayout.Space(10);

                if (GUILayout.Button($"Update Render Cache ({updateRenderCacheShortcut})"))
                {
                    PlayableDirector director = TimelineEditor.inspectedDirector;
                    if (null == director)
                    {
                        EditorUtility.DisplayDialog("Streaming Image Sequence",
                                                    "PlayableAsset is not loaded in scene. Please load the correct scene before doing this operation.",
                                                    "Ok");
                        return;
                    }

                    //Loop time
                    EditorCoroutineUtility.StartCoroutine(UpdateRenderCacheCoroutine(director, m_asset), this);
                }
            }
        }