Esempio n. 1
0
 public void Dispose()
 {
     UnityHelpers.Destroy(m_WorkTexture);
     m_WorkTexture = null;
     UnityHelpers.Destroy(m_VFLipMaterial);
     m_VFLipMaterial = null;
 }
Esempio n. 2
0
 public void Flip(RenderTexture target)
 {
     if (m_WorkTexture == null || m_WorkTexture.width != target.width || m_WorkTexture.height != target.height)
     {
         UnityHelpers.Destroy(m_WorkTexture);
         m_WorkTexture = new RenderTexture(target.width, target.height, target.depth, target.format, RenderTextureReadWrite.Linear);
     }
     Graphics.Blit(target, m_WorkTexture, m_VFLipMaterial);
     Graphics.Blit(m_WorkTexture, target);
 }
Esempio n. 3
0
        public static void UnregisterInputSettingObj(string assetId, RecorderInputSetting input)
        {
            var settingsRoot = GetInputsComponent(assetId);

            settingsRoot.m_Settings.Remove(input);
            UnityHelpers.Destroy(input);
#if UNITY_EDITOR
            EditorSceneManager.MarkSceneDirty(settingsRoot.gameObject.scene);
#endif
        }
        public void OnDestroy()
        {
            for (int i = 0; i < m_InputsSettingsAssets.Count; i++)
            {
                if (m_InputsSettingsAssets[i] is InputBinder)
                {
                    SceneHook.UnregisterInputSettingObj(ownerRecorderSettingsAssetId, m_InputsSettings[i]);
                }

                UnityHelpers.Destroy(m_InputsSettingsAssets[i], true);
            }
        }
Esempio n. 5
0
        void ReleaseAt(int index)
        {
            if (m_InputsSettingsAssets[index] is InputBinder)
            {
                SceneHook.UnregisterInputSettingObj(m_ParentAssetId, m_InputsSettings[index]);
            }

            UnityHelpers.Destroy(m_InputsSettingsAssets[index], true);

            m_InputsSettings[index]       = null;
            m_InputsSettingsAssets[index] = null;
        }
Esempio n. 6
0
        public override void RecordFrame(RecordingSession session)
        {
            if (m_Inputs.Count != 1)
            {
                throw new Exception("Unsupported number of sources");
            }

            var input = (BaseRenderTextureInput)m_Inputs[0];

            var width  = input.outputRT.width;
            var height = input.outputRT.height;

            var tex          = new Texture2D(width, height, m_Settings.m_OutputFormat != PNGRecordeOutputFormat.EXR ? TextureFormat.RGBA32 : TextureFormat.RGBAFloat, false);
            var backupActive = RenderTexture.active;

            RenderTexture.active = input.outputRT;
            tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
            tex.Apply();
            RenderTexture.active = backupActive;

            byte[] bytes;
            string ext;

            switch (m_Settings.m_OutputFormat)
            {
            case PNGRecordeOutputFormat.PNG:
                bytes = tex.EncodeToPNG();
                ext   = "png";
                break;

            case PNGRecordeOutputFormat.JPEG:
                bytes = tex.EncodeToJPG();
                ext   = "jpg";
                break;

            case PNGRecordeOutputFormat.EXR:
                bytes = tex.EncodeToEXR();
                ext   = "exr";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            UnityHelpers.Destroy(tex);

            var fileName = m_Settings.m_BaseFileName.BuildFileName(session, recordedFramesCount, width, height, ext);
            var path     = Path.Combine(m_Settings.m_DestinationPath.GetFullPath(), fileName);


            File.WriteAllBytes(path, bytes);
        }
Esempio n. 7
0
        public void Dispose()
        {
            if (m_Recorder != null)
            {
                if (recording)
                {
                    EndRecording();
                }

                UnityHelpers.Destroy(m_Recorder);
                UnityHelpers.Destroy(m_RecorderGO);
            }
        }
        void ReleaseAt(int index)
        {
#if UNITY_EDITOR
            bool isBinder = m_InputsSettingsAssets[index] is InputBinder;
            if (isBinder)
            {
                SceneHook.UnregisterInputSettingObj(ownerRecorderSettingsAssetId, m_InputsSettings[index]);
            }
#endif
            UnityHelpers.Destroy(m_InputsSettingsAssets[index], true);
#if UNITY_EDITOR
            AssetDatabase.SaveAssets();
#endif

            m_InputsSettings[index]       = null;
            m_InputsSettingsAssets[index] = null;
        }
        public void Dispose()
        {
            if (m_Recorder != null)
            {
                try
                {
                    if (recording)
                    {
                        EndRecording();
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }

                UnityHelpers.Destroy(m_Recorder);
                UnityHelpers.Destroy(m_RecorderGO);
            }
        }