Пример #1
0
        internal GameObject GetOrCreateEyeCameraObj(EyeType type)
        {
            ToggleWatcherCamera(true);

            var eyeAnchorName = GetEyeAnchorName(type);
            var eyeAnchorObj  = SRDSceneEnvironment.GetOrCreateChild(_watcherAnchorObj.transform, eyeAnchorName);

            var        eyeCameraName  = GetEyeCameraName(type);
            var        eyeCameraObjTf = eyeAnchorObj.transform.Find(eyeCameraName);
            GameObject eyeCameraObj;

            if (eyeCameraObjTf == null)
            {
                eyeCameraObj      = GameObject.Instantiate(_watcherCameraObj);
                eyeCameraObj.name = eyeCameraName;
                eyeCameraObj.transform.SetParent(eyeAnchorObj.transform);
            }
            else
            {
                eyeCameraObj      = eyeCameraObjTf.gameObject;
                _eyeCameras[type] = eyeCameraObj.GetComponent <Camera>();
                if (_eyeCameras[type] == null)
                {
                    _eyeCameras[type] = eyeCameraObj.AddComponent <Camera>();
                    _eyeCameras[type].CopyFrom(_watcherCameraObj.GetComponent <Camera>());
                }
            }

            SRDSceneEnvironment.InitializePose(eyeCameraObj.transform);
            return(eyeCameraObj);
        }
Пример #2
0
        /// <summary>
        /// A constructor of SRDCameras.
        /// </summary>
        /// <param name="manager">Must set a SRDManager object in the current scene</param>
        public SRDCameras(SRDManager manager)
        {
            _srdManager = manager;

            var watcherAnchorName = SRDHelper.SRDConstants.WatcherGameObjDefaultName;

            _watcherAnchorObj = SRDSceneEnvironment.GetOrCreateChild(_srdManager.transform, watcherAnchorName);

            var watcherCameraName = SRDHelper.SRDConstants.WatcherCameraGameObjDefaultName;

            _watcherCameraObj = SRDSceneEnvironment.GetOrCreateChild(_watcherAnchorObj.transform, watcherCameraName);

            _watcherCamera = SRDSceneEnvironment.GetOrAddComponent <Camera>(_watcherCameraObj);
            _eyeCameras    = new Dictionary <EyeType, Camera>();
        }
        private void Initialize()
        {
            _srdManager = SRDSceneEnvironment.GetSRDManager();
            _srdCameras = new SRDCameras(_srdManager);

            foreach (var type in _eyeTypes)
            {
                var eyeCameraObj = _srdCameras.GetOrCreateEyeCameraObj(type);
                _eyeCamera[type] = SRDSceneEnvironment.GetOrAddComponent <Camera>(eyeCameraObj);
                _eyeCamera[type].targetTexture = _eyeCamRenderTextureCache[type];

                var eyeAnchorName = SRDHelper.EyeSideName[type] + SRDHelper.SRDConstants.EyeAnchorGameObjDefaultName;
                var eyeAnchor     = SRDSceneEnvironment.GetOrCreateChild(_srdCameras.AnchorTransform, eyeAnchorName);
                _eyeTransform[type] = eyeAnchor.transform;
            }
            _srdCameras.RemoveSourceCamera();
        }