void RecordButtonOnGui()
        {
            if (m_Editor == null || m_Editor.target == null)
            {
                return;
            }

            switch (m_State)
            {
            case EState.Idle:
            {
                var errors = new List <string>();
                using (new EditorGUI.DisabledScope(!m_Editor.ValidityCheck(errors)))
                {
                    if (GUILayout.Button("Start Recording"))
                    {
                        StartRecording();
                    }
                }
                break;
            }

            case EState.WaitingForPlayModeToStartRecording:
            {
                using (new EditorGUI.DisabledScope(Time.frameCount - m_FrameCount < 5))
                {
                    if (GUILayout.Button("Stop Recording"))
                    {
                        StopRecording();
                    }
                }
                break;
            }

            case EState.Recording:
            {
                var recorderGO = SceneHook.FindRecorder((RecorderSettings)m_Editor.target);
                if (recorderGO == null)
                {
                    GUILayout.Button("Start Recording");     // just to keep the ui system happy.
                    m_State      = EState.Idle;
                    m_FrameCount = 0;
                }
                else
                {
                    if (GUILayout.Button("Stop Recording"))
                    {
                        StopRecording();
                    }
                    UpdateRecordingProgress(recorderGO);
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#2
0
        void RecordButtonOnGui()
        {
            if (m_Editor == null || m_Editor.target == null)
            {
                return;
            }

            switch (m_State)
            {
            case EState.Idle:
            {
                using (new EditorGUI.DisabledScope(!m_Editor.isValid))
                {
                    if (GUILayout.Button("Start Recording"))
                    {
                        StartRecording();
                    }
                }
                break;
            }

            case EState.WaitingForPlayModeToStartRecording:
            {
                using (new EditorGUI.DisabledScope(true))
                    GUILayout.Button("Stop Recording");     // passive
                break;
            }

            case EState.Recording:
            {
                var recorderGO = SceneHook.FindRecorder((RecorderSettings)m_Editor.target);
                if (recorderGO == null)
                {
                    GUILayout.Button("Start Recording");     // just to keep the ui system happy.
                    m_State = EState.Idle;
                }
                else
                {
                    if (GUILayout.Button("Stop Recording"))
                    {
                        StopRecording();
                    }
                    UpdateRecordingProgress(recorderGO);
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#3
0
 void StopRecording()
 {
     if (m_Editor != null)
     {
         var settings = (RecorderSettings)m_Editor.target;
         if (settings != null)
         {
             var recorderGO = SceneHook.FindRecorder(settings);
             if (recorderGO != null)
             {
                 UnityHelpers.Destroy(recorderGO);
             }
         }
     }
 }
 void StopRecording()
 {
     if (m_Editor != null)
     {
         var settings = (RecorderSettings)m_Editor.target;
         if (settings != null)
         {
             var recorderGO = SceneHook.FindRecorder(settings);
             if (recorderGO != null)
             {
                 UnityHelpers.Destroy(recorderGO);
             }
         }
     }
     m_FrameCount = 0;
     m_State      = EState.Idle;
 }