void CleanupSettingsAsset()
 {
     UnityHelpers.Destroy(m_WindowSettingsAsset, true);
     m_WindowSettingsAsset = ScriptableObject.CreateInstance <RecorderWindowSettings>();
     AssetDatabase.CreateAsset(m_WindowSettingsAsset, FRPackagerPaths.GetRecorderRootPath() + "/RecorderWindowSettings.asset");
     AssetDatabase.Refresh();
 }
Esempio n. 2
0
        static void GenerateAssetStorePackage()
        {
            var rootPath = FRPackagerPaths.GetRecorderRootPath();
            var type     = Type.GetType("UnityEditor.Recorder.MovieRecorderPackager");

            if (type != null)
            {
                var method = type.GetMethod("GeneratePackage");
                method.Invoke(null, null);
                AssetDatabase.Refresh();
            }
            UpdateVersion();

            var files = new []
            {
                Path.Combine(rootPath, "Recorder_install.pdf"),
                Path.Combine(rootPath, "Framework.meta"),
                Path.Combine(rootPath, "Framework/Core"),
                Path.Combine(rootPath, "Framework/Inputs"),
                Path.Combine(rootPath, "Framework/Recorders"),
                Path.Combine(rootPath, "Framework/Packager/Editor"),
                Path.Combine(rootPath, "Extensions/UTJ"),
                Path.Combine(rootPath, "Extensions/FCIntegration"),
                Path.Combine(rootPath, "Extensions/MovieRecorder/Packaging"),
            };
            var destFile = k_PackageName + " " + RecorderVersion.Stage + " v" + RecorderVersion.Version + ".unitypackage";

            AssetDatabase.ExportPackage(files, destFile, ExportPackageOptions.Recurse);
            Debug.Log("Generated package: " + destFile);
        }
Esempio n. 3
0
        public void OnGUI()
        {
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            GUILayout.BeginVertical();
            GUILayout.Label(s_Header, GUIStyle.none);

            GUILayout.BeginHorizontal();
            GUILayout.Space(52f);
            GUILayout.Label("Recorder " + RecorderVersion.Stage, EditorStyles.boldLabel);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(52f);
            GUILayout.Label(string.Format("Version {0}", RecorderVersion.Tag));
            GUILayout.EndHorizontal();
            GUILayout.Space(4);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            var text = "The Unity Recorder package is a collection of Recorders that allow in-game capturing of data and saving it. For example; generate an mp4 file from a game session.\r\n\r\nIn support to the recorders, it provides a graphical interface that is used to manually trigger recording sessions, which take care of: entering play mode, recording requested data and exiting play mode when done. It also supports triggering recording sessions from user scripts and timeline tracks.\r\n\r\nThe Recorder is aimed at extensibility and is implemented as a plugin system, where anyone can create new recorders and have them seamlessly integrate into the Unity Recorder ecosystem, while maximizing code reuse.";

            float textWidth        = position.width - 10;
            float textHeight       = EditorStyles.wordWrappedLabel.CalcHeight(new GUIContent(text), textWidth);
            Rect  creditsNamesRect = new Rect(5, 120, textWidth, textHeight);

            GUI.Label(creditsNamesRect, text, EditorStyles.wordWrappedLabel);
            GUILayout.Space(25);
            GUILayout.Space(textHeight);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("View user manual"))
            {
                var file = FRPackagerPaths.GetFrameRecorderPath() + "/Recorder_install.pdf";
                Debug.Log(file);
                Application.OpenURL(file);
                this.Close();
            }
            GUILayout.Space(25);
            if (GUILayout.Button("Want to write a recorder?"))
            {
                Application.OpenURL("https://github.com/Unity-Technologies/GenericFrameRecorder/blob/master/README.md");
                this.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Unity's User forum"))
            {
                Application.OpenURL("https://forum.unity.com/threads/unity-recorder-update.509458/");
                this.Close();
            }
            GUILayout.EndHorizontal();
        }
 static MovieRecorderPackagerInternal() // auto extracts
 {
     if (AutoExtractAllowed && AudioRecordingAvailable && MovieRecordingAvailable)
     {
         var pkgFile = Path.Combine(FRPackagerPaths.GetRecorderRootPath(), "Extensions/MovieRecorder/Packaging/" + k_PackageName);
         var tsFile  = Path.Combine(FRPackagerPaths.GetRecorderRootPath(), "Extensions/MovieRecorder/Packaging/TS.txt");
         var recDir  = Path.Combine(FRPackagerPaths.GetRecorderRootPath(), "Extensions/MovieRecorder/Recorder");
         if (File.Exists(pkgFile) &&
             (!Directory.Exists(recDir) || File.GetLastWriteTime(pkgFile) > File.GetLastWriteTime(tsFile).AddMinutes(5))) // extra 5min to compensate for package write duration
         {
             Debug.Log("Importing MovieRecorder...");
             AssetDatabase.ImportPackage(pkgFile, false);
         }
     }
 }
Esempio n. 5
0
        static void UpdateVersion()
        {
            var path   = FRPackagerPaths.GetRecorderVersionFilePath();
            var script = File.ReadAllText(path);

            var tag         = "public const string Version = ";
            var startOffset = script.IndexOf(tag);
            var endOffset   = script.IndexOf("\"", startOffset + tag.Length + 1);

            var pattern = script.Substring(startOffset, endOffset - startOffset);

            startOffset = pattern.LastIndexOf(".");
            var newValue = pattern.Substring(0, startOffset + 1) + DateTime.Now.ToString("yyMMdd-hh");

            script = script.Replace(pattern, newValue);
            File.WriteAllText(path, script);
        }
        static void UpdateVersion(int delta)
        {
            var path   = FRPackagerPaths.GetRecorderVersionFilePath();
            var script = File.ReadAllText(path);

            var tag         = "public static int BuildNumber";
            var startOffset = script.IndexOf(tag);

            var endOffset = script.IndexOf(";", startOffset);
            var pattern   = script.Substring(startOffset, endOffset - startOffset);

            RecorderVersion.BuildNumber += delta;
            script = script.Replace(pattern, string.Format("public static int BuildNumber = {0}", RecorderVersion.BuildNumber));
            File.WriteAllText(path, script);
            AssetDatabase.Refresh();

            Debug.Log("Version Tag set to: " + RecorderVersion.Tag);
        }
        public static void GeneratePackage()
        {
            var rootPath = FRPackagerPaths.GetRecorderRootPath();

            File.WriteAllText(Path.Combine(rootPath, "Extensions/MovieRecorder/Packaging/TS.txt"), DateTime.Now.ToString());

            var files = new []
            {
                Path.Combine(rootPath, "Extensions/MovieRecorder/Recorder"),
                Path.Combine(rootPath, "Extensions/MovieRecorder/Audio"),
                Path.Combine(rootPath, "Extensions/MovieRecorder/Recorder"),
                Path.Combine(rootPath, "Extensions/MovieRecorder/Packaging/Editor"),
                Path.Combine(rootPath, "Extensions/MovieRecorder/Packaging/TS.txt"),
            };
            var destFile = Path.Combine(rootPath, "Extensions/MovieRecorder/Packaging/MovieRecorder.unitypackage");

            AssetDatabase.ExportPackage(files, destFile, ExportPackageOptions.Recurse);
            Debug.Log("Generated package: " + destFile);
        }
        static void GenerateAssetStorePackage()
        {
            var rootPath = FRPackagerPaths.GetRecorderRootPath();

            UpdateVersion(1);

            var files = new []
            {
                Path.Combine(rootPath, "Recorder_install.pdf"),
                Path.Combine(rootPath, "Framework.meta"),
                Path.Combine(rootPath, "Framework/Core"),
                Path.Combine(rootPath, "Framework/Inputs"),
                Path.Combine(rootPath, "Framework/Recorders"),
                Path.Combine(rootPath, "Framework/Packager/Editor"),
                Path.Combine(rootPath, "Extensions/UTJ"),
                Path.Combine(rootPath, "Extensions/FCIntegration"),
                Path.Combine(rootPath, "Extensions/MovieRecorder"),
            };
            var destFile = k_PackageName + " " + RecorderVersion.Stage + " v" + RecorderVersion.Tag + ".unitypackage";

            AssetDatabase.ExportPackage(files, destFile, ExportPackageOptions.Recurse);
            Debug.Log("Generated package: " + destFile);
        }
        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, FRPackagerPaths.GetRecorderRootPath() + "/RecorderWindowSettings.asset");
                                AssetDatabase.Refresh();
                            }
                        }

                        m_recorderSelector = new RecorderSelector(OnRecorderSelected, false);
                        m_recorderSelector.Init(m_WindowSettingsAsset.m_Settings, m_Category);
                    }

                    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();
                    }
                }
            }
        }