public void OnGUI() { m_LastRepaint = DateTime.Now; // Bug? work arround: on Stop play, Enable is not called. if (m_Editor != null && m_Editor.target == null) { UnityHelpers.Destroy(m_Editor); m_Editor = null; m_recorderSelector = null; } if (m_recorderSelector == null) { if (m_WindowSettingsAsset == null) { var candidates = AssetDatabase.FindAssets("t:RecorderWindowSettings"); if (candidates.Length > 0) { var path = AssetDatabase.GUIDToAssetPath(candidates[0]); m_WindowSettingsAsset = AssetDatabase.LoadAssetAtPath <RecorderWindowSettings>(path); } else { m_WindowSettingsAsset = ScriptableObject.CreateInstance <RecorderWindowSettings>(); AssetDatabase.CreateAsset(m_WindowSettingsAsset, "Assets/FrameRecordingSettings.asset"); AssetDatabase.SaveAssets(); } } m_recorderSelector = new RecorderSelector(OnRecorderSelected, true); m_recorderSelector.Init(m_WindowSettingsAsset.m_Settings, m_StartingCategory); } if (m_State == EState.WaitingForPlayModeToStartRecording && EditorApplication.isPlaying) { DelayedStartRecording(); } using (new EditorGUI.DisabledScope(EditorApplication.isPlaying)) m_recorderSelector.OnGui(); if (m_Editor != null) { m_Editor.showBounds = true; using (new EditorGUI.DisabledScope(EditorApplication.isPlaying)) { EditorGUILayout.Separator(); m_Editor.OnInspectorGUI(); EditorGUILayout.Separator(); } RecordButtonOnGui(); } }
void ResetSettings() { UnityHelpers.Destroy(m_Editor); m_Editor = null; m_recorderSelector = null; var path = AssetDatabase.GetAssetPath(m_WindowSettingsAsset); UnityHelpers.Destroy(m_WindowSettingsAsset, true); AssetDatabase.DeleteAsset(path); AssetDatabase.Refresh(ImportAssetOptions.Default); m_WindowSettingsAsset = null; }
public void OnGUI() { try { m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos); try { m_LastRepaint = DateTime.Now; // Bug? work arround: on Stop play, Enable is not called. if (m_Editor != null && m_Editor.target == null) { UnityHelpers.Destroy(m_Editor); m_Editor = null; m_recorderSelector = null; } if (m_recorderSelector == null) { if (m_WindowSettingsAsset == null) { var candidates = AssetDatabase.FindAssets("t:RecorderWindowSettings"); if (candidates.Length > 0) { var path = AssetDatabase.GUIDToAssetPath(candidates[0]); m_WindowSettingsAsset = AssetDatabase.LoadAssetAtPath <RecorderWindowSettings>(path); if (m_WindowSettingsAsset == null) { AssetDatabase.DeleteAsset(path); } } if (m_WindowSettingsAsset == null) { m_WindowSettingsAsset = ScriptableObject.CreateInstance <RecorderWindowSettings>(); AssetDatabase.CreateAsset(m_WindowSettingsAsset, "Assets/FrameRecordingSettings.asset"); AssetDatabase.Refresh(); } } m_recorderSelector = new RecorderSelector(OnRecorderSelected, true); m_recorderSelector.Init(m_WindowSettingsAsset.m_Settings, m_StartingCategory); } if (m_State == EState.WaitingForPlayModeToStartRecording && EditorApplication.isPlaying) { DelayedStartRecording(); } using (new EditorGUI.DisabledScope(EditorApplication.isPlaying)) m_recorderSelector.OnGui(); if (m_Editor != null) { m_Editor.showBounds = true; using (new EditorGUI.DisabledScope(EditorApplication.isPlaying)) { EditorGUILayout.Separator(); m_Editor.OnInspectorGUI(); EditorGUILayout.Separator(); } RecordButtonOnGui(); GUILayout.Space(50); } } finally { EditorGUILayout.EndScrollView(); } } catch (ExitGUIException) { } catch (Exception ex) { if (m_State == EState.Recording) { try { Debug.LogError("Aborting recording due to an exception!\n" + ex.ToString()); StopRecording(); } catch (Exception) {} } else { EditorGUILayout.HelpBox("An exception was raised while editing the settings. This can be indicative of corrupted settings.", MessageType.Warning); if (GUILayout.Button("Reset settings to default")) { ResetSettings(); } } Debug.LogException(ex); } }
public void OnEnable() { m_recorderSelector = null; }