コード例 #1
0
 public void Dispose()
 {
     UnityHelpers.Destroy(m_WorkTexture);
     m_WorkTexture = null;
     UnityHelpers.Destroy(m_VFLipMaterial);
     m_VFLipMaterial = null;
 }
コード例 #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);
 }
コード例 #3
0
ファイル: SceneHook.cs プロジェクト: TashaSkyUp/Staging
        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
        }
コード例 #4
0
        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);
            }
        }
コード例 #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;
        }
コード例 #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);
        }
コード例 #7
0
        public void Dispose()
        {
            if (m_Recorder != null)
            {
                if (recording)
                {
                    EndRecording();
                }

                UnityHelpers.Destroy(m_Recorder);
                UnityHelpers.Destroy(m_RecorderGO);
            }
        }
コード例 #8
0
        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;
        }
コード例 #9
0
        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);
            }
        }