コード例 #1
0
        //void GarbageCollectionProcess()
        //{
        //  double deltaTime = 1 / (double)frameRate;
        //  int sleepTime = (int)(deltaTime * 1000);
        //  while (status != CaptureStatus.READY)
        //  {
        //    Thread.Sleep(sleepTime);
        //    System.GC.Collect();
        //  }

        //  garbageThreadRunning = false;
        //}

        #endregion

        #region Unity Lifecycle

        protected new void Awake()
        {
            base.Awake();

            if (ffmpegEncoder == null)
            {
                ffmpegEncoder = GetComponentInChildren <FFmpegEncoder>(true);
                if (ffmpegEncoder == null)
                {
                    Debug.LogErrorFormat(LOG_FORMAT,
                                         "Component FFmpegEncoder not found, please use prefab or follow the document to set up video capture.");
                    return;
                }
            }

            if (gpuEncoder == null)
            {
                gpuEncoder = GetComponentInChildren <GPUEncoder>(true);
                if (gpuEncoder == null)
                {
                    Debug.LogErrorFormat(LOG_FORMAT,
                                         "Component hardware encoder not found, please use prefab or follow the document to set up video capture.");
                }
            }

            if (nvidiaEncoder == null)
            {
                nvidiaEncoder = GetComponentInChildren <NvidiaEncoder>(true);
                if (nvidiaEncoder == null)
                {
                    Debug.LogErrorFormat(LOG_FORMAT,
                                         "Component nvidia encoder not found, please use prefab or follow the document to set up video capture.");
                }
            }
        }
コード例 #2
0
ファイル: ScreenShot.cs プロジェクト: czhowl/RR-Research
        private void Awake()
        {
            if (ffmpegEncoder == null)
            {
                ffmpegEncoder = GetComponentInChildren <FFmpegEncoder>(true);
                if (ffmpegEncoder == null)
                {
                    Debug.LogErrorFormat(LOG_FORMAT,
                                         "Component software Encoder not found, please use prefab or follow the document to set up video capture.");
                }
            }

            if (gpuEncoder == null)
            {
                gpuEncoder = GetComponentInChildren <GPUEncoder>(true);
                if (gpuEncoder == null)
                {
                    Debug.LogErrorFormat(LOG_FORMAT,
                                         "Component GPU encoder not found, please use prefab or follow the document to set up video capture.");
                }
            }

            if (ffmpegEncoder != null)
            {
                ffmpegEncoder.OnComplete += OnEncoderComplete;
            }

#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            if (gpuEncoder != null)
            {
                gpuEncoder.gameObject.SetActive(true);
                gpuEncoder.OnComplete += OnEncoderComplete;
            }
#endif
        }
コード例 #3
0
        //void OnRenderImage(RenderTexture src, RenderTexture dst)
        //{
        //  if (captureMode == CaptureMode.REGULAR &&
        //    outputTexture && captureSource == CaptureSource.CAMERA)
        //  {
        //    Graphics.Blit(src, dst);
        //    Graphics.Blit(null, outputTexture);
        //    StartCoroutine(BlitRegularTextures());
        //  }
        //}

        void Awake()
        {
            if (singleton != null)
            {
                return;
            }
            singleton    = this;
            instantiated = true;

            captureStarted    = false;
            screenshotStarted = false;

            // Retrieve attached VR devie for sound and microphone capture in VR
            // If expected VR device is not attached, it will capture default audio device
#if UNITY_2019_1_OR_NEWER
            UnityEngine.XR.InputDevice inputDevice = new UnityEngine.XR.InputDevice();
            string vrDeviceName = string.IsNullOrEmpty(inputDevice.name) ? "" : inputDevice.name.ToLower();
#elif UNITY_2017_2_OR_NEWER
            string vrDeviceName = UnityEngine.XR.XRDevice.model.ToLower();
#else
            string vrDeviceName = "";
#endif

            if (vrDeviceName.Contains("rift"))
            {
                attachedHMD = VRDeviceType.OCULUS_RIFT;
            }
            else if (vrDeviceName.Contains("vive"))
            {
                attachedHMD = VRDeviceType.HTC_VIVE;
            }
            else
            {
                attachedHMD = VRDeviceType.UNKNOWN;
            }
        }
コード例 #4
0
        void Awake()
        {
            if (singleton != null)
            {
                return;
            }
            singleton    = this;
            instantiated = true;

            captureStarted    = false;
            screenshotStarted = false;
            //regularCamera = GetComponent<Camera>();
            if (regularCamera)
            {
                regularCamera.enabled = false;
            }
            if (cubemapCamera)
            {
                cubemapCamera.enabled = false;
            }

            OnError += EncoderErrorLog;

            // Resolution preset settings
            ResolutionPresetSettings();

            //// Preview video preset
            //if (previewVideoPreset == ResolutionPreset._720P)
            //{
            //  previewVideoWidth = 1280;
            //  previewVideoHeight = 720;
            //  previewVideoBitRate = 2000;
            //}
            //else if (previewVideoPreset == ResolutionPreset._1080P)
            //{
            //  previewVideoWidth = 1920;
            //  previewVideoHeight = 1080;
            //  previewVideoBitRate = 4000;
            //}
            //else if (previewVideoPreset == ResolutionPreset._4K)
            //{
            //  previewVideoWidth = 4096;
            //  previewVideoHeight = 2048;
            //  previewVideoBitRate = 10000;
            //}

            // Retrieve attached VR devie for sound and microphone capture in VR
            // If expected VR device is not attached, it will capture default audio device
            string vrDeviceName = UnityEngine.XR.XRDevice.model.ToLower();

            if (vrDeviceName.Contains("rift"))
            {
                attachedHMD = VRDeviceType.OCULUS_RIFT;
            }
            else if (vrDeviceName.Contains("vive"))
            {
                attachedHMD = VRDeviceType.HTC_VIVE;
            }
            else
            {
                attachedHMD = VRDeviceType.UNKNOWN;
            }
        }