void OnRecorderSelected(Type selectedRecorder)
        {
            var clip = (RecorderClip)target;

            if (m_Editor != null)
            {
                UnityHelpers.Destroy(m_Editor);
                m_Editor = null;
            }

            if (selectedRecorder == null)
            {
                return;
            }

            if (clip.settings != null && RecordersInventory.GetRecorderInfo(selectedRecorder).settingsType != clip.settings.GetType())
            {
                Undo.DestroyObjectImmediate(clip.settings);
                clip.settings = null;
            }

            if (clip.settings == null)
            {
                clip.settings = RecordersInventory.CreateDefaultRecorderSettings(selectedRecorder);
                Undo.RegisterCreatedObjectUndo(clip.settings, "Recorder Create Settings");
                AssetDatabase.AddObjectToAsset(clip.settings, clip);
            }

            m_Editor = (RecorderEditor)CreateEditor(clip.settings);
        }
Esempio n. 2
0
        void OnRecorderSelected(Type selectedRecorder)
        {
            var clip = (RecorderClip)target;

            if (m_Editor != null)
            {
                UnityHelpers.Destroy(m_Editor);
                m_Editor = null;
            }

            if (selectedRecorder == null)
            {
                return;
            }

            if (clip.settings != null && RecordersInventory.GetRecorderInfo(selectedRecorder).settingsType != clip.settings.GetType())
            {
                UnityHelpers.Destroy(clip.settings, true);
                clip.settings = null;
            }

            if (clip.settings == null)
            {
                clip.settings = RecordersInventory.CreateDefaultRecorderSettings(selectedRecorder);

                AssetDatabase.AddObjectToAsset(clip.settings, clip);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }

            m_Editor = (RecorderEditor)CreateEditorWithContext(new UnityObject[] { clip.settings }, SceneHook.GetRecorderBindings());
            AssetDatabase.Refresh();
        }
        public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom)
        {
            var rClip = clip.asset as RecorderClip;

            var rDuplicateClip = clonedFrom == null ? null : clonedFrom.asset as RecorderClip;

            if (rDuplicateClip != null && rDuplicateClip.settings != null)
            {
                // Clone by doing a deepcopy
                rClip.settings      = UnityEngine.Object.Instantiate(rDuplicateClip.settings);
                rClip.settings.name = clip.displayName;
                AssetDatabase.AddObjectToAsset(rClip.settings, rClip);
            }
            else
            {
                // Create a new setting
                rClip.settings      = RecordersInventory.CreateDefaultRecorderSettings(typeof(MovieRecorderSettings));
                rClip.settings.name = clip.displayName;
                AssetDatabase.AddObjectToAsset(rClip.settings, rClip);
                rClip.PushTimelineIntoRecorder(rClip.FindTimelineAsset());
            }
            Undo.RegisterCreatedObjectUndo(rClip.settings, "Recorded Settings Created");
            AssetDatabase.SaveAssets();
        }