コード例 #1
0
ファイル: RecorderSelector.cs プロジェクト: ZaK14120/ARS
        public void Init(RecorderSettings settings, string startingCategory = "")
        {
            // Pre existing settings obj?
            if (settings != null)
            {
                var recInfo = RecordersInventory.GetRecorderInfo(settings.recorderType);

                // category value overrides existing settings.
                if (!string.IsNullOrEmpty(startingCategory))
                {
                    if (string.Compare(recInfo.category, startingCategory, StringComparison.InvariantCultureIgnoreCase) != 0)
                    {
                        // forced another category, flush existing settings obj.
                        SetCategory(startingCategory);
                        SelectRecorder(GetRecorderFromIndex(0));
                    }
                }

                // Not invalidated by category, so set and we are done
                if (settings != null)
                {
                    SetCategory(recInfo.category);
                    SelectRecorder(settings.recorderType);
                    return;
                }
            }
            else
            {
                SetCategory(startingCategory);
            }
        }
コード例 #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())
            {
                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);
        }
コード例 #3
0
        public void OnRecorderSelected()
        {
            if (m_Editor != null)
            {
                UnityHelpers.Destroy(m_Editor);
                m_Editor = null;
            }

            if (m_recorderSelector.selectedRecorder == null)
            {
                return;
            }

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

            if (m_WindowSettingsAsset.m_Settings == null)
            {
                m_WindowSettingsAsset.m_Settings = RecordersInventory.GenerateNewSettingsAsset(m_WindowSettingsAsset, m_recorderSelector.selectedRecorder);
            }
            m_Editor = Editor.CreateEditor(m_WindowSettingsAsset.m_Settings) as RecorderEditor;
            AssetDatabase.Refresh();
        }
コード例 #4
0
        public void OnRecorderSelected()
        {
            var clip = this.target as RecorderClip;

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

            if (m_recorderSelector.selectedRecorder == null)
            {
                return;
            }

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

            if (clip.m_Settings == null)
            {
                clip.m_Settings = RecordersInventory.GenerateNewSettingsAsset(clip, m_recorderSelector.selectedRecorder);
            }
            m_Editor = Editor.CreateEditor(clip.m_Settings) as RecorderEditor;
            AssetDatabase.Refresh();
        }
コード例 #5
0
        void StartRecording(bool autoExitPlayMode)
        {
            var settings = (RecorderSettings)m_Editor.target;
            var go       = FrameRecorderGOControler.HookupRecorder(!settings.m_Verbose);
            var session  = new RecordingSession()
            {
                m_Recorder   = RecordersInventory.GenerateNewRecorder(m_recorderSelector.selectedRecorder, settings),
                m_RecorderGO = go,
            };

            var component = go.AddComponent <RecorderComponent>();

            component.session          = session;
            component.autoExitPlayMode = autoExitPlayMode;

            if (session.SessionCreated() && session.BeginRecording())
            {
                m_State = EState.Recording;
            }
            else
            {
                m_State = EState.Idle;
                StopRecording();
            }
        }
コード例 #6
0
        public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
        {
            var playable = ScriptPlayable <RecorderPlayableBehaviour> .Create(graph);

            var behaviour = playable.GetBehaviour();

            if (recorderType != null && UnityHelpers.IsPlaying())
            {
                behaviour.session = new RecordingSession()
                {
                    m_Recorder   = RecordersInventory.GenerateNewRecorder(recorderType, m_Settings),
                    m_RecorderGO = SceneHook.HookupRecorder(),
                };
                behaviour.OnEnd = () =>
                {
                    try
                    {
                        if (OnClipDone != null)
                        {
                            OnClipDone(this);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Log("OnClipDone call back generated an exception: " + ex.Message);
                        Debug.LogException(ex);
                    }
                };
            }
            return(playable);
        }
コード例 #7
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();
        }
コード例 #8
0
ファイル: RecorderClip.cs プロジェクト: ZaK14120/ARS
        public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
        {
            var playable = ScriptPlayable <RecorderPlayableBehaviour> .Create(graph);

            var behaviour = playable.GetBehaviour();

            if (recorderType != null && UnityHelpers.IsPlaying())
            {
                behaviour.session = new RecordingSession()
                {
                    m_Recorder   = RecordersInventory.GenerateNewRecorder(recorderType, m_Settings),
                    m_RecorderGO = FrameRecorderGOControler.HookupRecorder(!m_Settings.m_Verbose),
                };
            }
            return(playable);
        }
コード例 #9
0
        void StartRecording(bool autoExitPlayMode)
        {
            var settings = (RecorderSettings)m_Editor.target;
            var go       = FrameRecorderGOControler.HookupRecorder();
            var session  = new RecordingSession()
            {
                m_Recorder         = RecordersInventory.GenerateNewRecorder(m_recorderSelector.selectedRecorder, settings),
                m_RecorderGO       = go,
                m_RecordingStartTS = Time.time / Time.timeScale,
                m_FrameIndex       = 0
            };

            var component = go.AddComponent <RecorderComponent>();

            component.session          = session;
            component.autoExitPlayMode = autoExitPlayMode;

            session.BeginRecording();
            m_State = EState.Recording;
        }
コード例 #10
0
        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();
        }