Esempio n. 1
0
    private void SetValid(bool value)
    {
        if (value && m_externalCamera == null && SteamVR_Render.instance.externalCamera == null && File.Exists(m_configPath))
        {
            // don't know why SteamVR_ExternalCamera must be instantiated from the prefab
            // when create SteamVR_ExternalCamera using AddComponent, errors came out when disabling
            var prefab = Resources.Load <GameObject>("SteamVR_ExternalCamera");
            if (prefab == null)
            {
                Debug.LogError("SteamVR_ExternalCamera prefab not found!");
            }
            else
            {
                var ctrlMgr = Instantiate(prefab);
                var extCam  = ctrlMgr.transform.GetChild(0);
                extCam.gameObject.name = "SteamVR External Camera";
                extCam.SetParent(transform, false);
                DestroyImmediate(extCam.GetComponent <SteamVR_TrackedObject>());
                DestroyImmediate(ctrlMgr);

                m_externalCamera = extCam.GetComponent <SteamVR_ExternalCamera>();
                SteamVR_Render.instance.externalCamera = m_externalCamera;
                m_externalCamera.configPath            = m_configPath;
                m_externalCamera.ReadConfig();
            }
        }

        if (m_externalCamera != null)
        {
            m_externalCamera.gameObject.SetActive(value);
        }
    }
        private void InternalSetQuadViewActive(bool value)
        {
            if (value && m_externalCamera == null && !string.IsNullOrEmpty(m_configPath) && File.Exists(m_configPath))
            {
                // don't know why SteamVR_ExternalCamera must be instantiated from the prefab
                // when create SteamVR_ExternalCamera using AddComponent, errors came out when disabling
                var prefab = Resources.Load <GameObject>("SteamVR_ExternalCamera");
                if (prefab == null)
                {
                    Debug.LogError("SteamVR_ExternalCamera prefab not found!");
                }
                else
                {
                    var ctrlMgr = Instantiate(prefab);
                    var extCam  = ctrlMgr.transform.GetChild(0);
                    extCam.gameObject.name = "SteamVR External Camera";
                    extCam.SetParent(transform, false);
                    DestroyImmediate(extCam.GetComponent <SteamVR_TrackedObject>());
                    DestroyImmediate(ctrlMgr);

                    m_externalCamera = extCam.GetComponent <SteamVR_ExternalCamera>();
                    SteamVR_Render.instance.externalCamera = m_externalCamera;

                    // resolve config file
                    m_externalCamera.enabled    = false;
                    m_externalCamera.configPath = m_configPath;
                    m_externalCamera.ReadConfig();
                    m_externalCamera.enabled = true; // to preserve sceneResolutionScale on enabled

                    // resolve RenderTexture
                    m_externalCamera.AttachToCamera(SteamVR_Render.Top());
                    var w   = Screen.width / 2;
                    var h   = Screen.height / 2;
                    var cam = m_externalCamera.GetComponentInChildren <Camera>();
                    if (cam.targetTexture == null || cam.targetTexture.width != w || cam.targetTexture.height != h)
                    {
                        var tex = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32, QualitySettings.activeColorSpace == ColorSpace.Linear ? RenderTextureReadWrite.Linear : RenderTextureReadWrite.Default);
                        tex.antiAliasing  = QualitySettings.antiAliasing == 0 ? 1 : QualitySettings.antiAliasing;
                        cam.targetTexture = tex;
                    }
                }
            }

            if (m_externalCamera != null)
            {
                m_externalCamera.gameObject.SetActive(value);

                if (value)
                {
                    VivePose.AddNewPosesListener(this);
                }
                else
                {
                    VivePose.RemoveNewPosesListener(this);
                }
            }
        }
Esempio n. 3
0
    private void Awake()
    {
        if (externalCamera == null && File.Exists(externalCameraConfigPath))
        {
            var prefab   = Resources.Load <GameObject>("SteamVR_ExternalCamera");
            var instance = Instantiate(prefab);
            instance.gameObject.name = "External Camera";

            externalCamera            = instance.transform.GetChild(0).GetComponent <SteamVR_ExternalCamera>();
            externalCamera.configPath = externalCameraConfigPath;
            externalCamera.ReadConfig();
        }
    }
        private void Awake()
        {
            if (externalCamera == null && File.Exists(externalCameraConfigPath))



            {
                GameObject original   = Resources.Load <GameObject>("SteamVR_ExternalCamera");
                GameObject gameObject = Object.Instantiate(original);
                gameObject.gameObject.name = "External Camera";
                externalCamera             = gameObject.transform.GetChild(0).GetComponent <SteamVR_ExternalCamera>();
                externalCamera.configPath  = externalCameraConfigPath;
                externalCamera.ReadConfig();
            }
        }
Esempio n. 5
0
    void Awake()
    {
        var go = new GameObject("cameraMask");

        go.transform.parent = transform;
        cameraMask          = go.AddComponent <SteamVR_CameraMask>();

        if (externalCamera == null && System.IO.File.Exists(externalCameraConfigPath))
        {
            var prefab   = Resources.Load <GameObject>("SteamVR_ExternalCamera");
            var instance = Instantiate(prefab);
            instance.gameObject.name = "External Camera";

            externalCamera            = instance.transform.GetChild(0).GetComponent <SteamVR_ExternalCamera>();
            externalCamera.configPath = externalCameraConfigPath;
            externalCamera.ReadConfig();
        }
    }
Esempio n. 6
0
    void Awake()
    {
        var go = new GameObject("cameraMask");
        go.transform.parent = transform;
        cameraMask = go.AddComponent<SteamVR_CameraMask>();

        if (externalCamera == null && System.IO.File.Exists(externalCameraConfigPath))
        {
            var prefab = Resources.Load<GameObject>("SteamVR_ExternalCamera");
            var instance = Instantiate(prefab);
            instance.gameObject.name = "External Camera";

            externalCamera = instance.transform.GetChild(0).GetComponent<SteamVR_ExternalCamera>();
            externalCamera.configPath = externalCameraConfigPath;
            externalCamera.ReadConfig();
        }
    }