Ejemplo n.º 1
0
        private void Awake()
        {
            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();
            }
        }
Ejemplo n.º 2
0
        private bool CheckExternalCamera()
        {
            if (doesPathExist == false)
            {
                return(false);
            }
            else if (doesPathExist == null)
            {
                doesPathExist = System.IO.File.Exists(externalCameraConfigPath);
            }

            if (externalCamera == null && doesPathExist == true)
            {
                GameObject prefab = Resources.Load <GameObject>("SteamVR_ExternalCamera");
                if (prefab == null)
                {
                    doesPathExist = false;
                    return(false);
                }
                else
                {
                    if (SteamVR_Settings.instance.legacyMixedRealityCamera)
                    {
                        if (SteamVR_ExternalCamera_LegacyManager.hasCamera == false)
                        {
                            return(false);
                        }

                        GameObject instance = Instantiate(prefab);
                        instance.gameObject.name = "External Camera";

                        externalCamera            = instance.transform.GetChild(0).GetComponent <SteamVR_ExternalCamera>();
                        externalCamera.configPath = externalCameraConfigPath;
                        externalCamera.ReadConfig();
                        externalCamera.SetupDeviceIndex(SteamVR_ExternalCamera_LegacyManager.cameraIndex);
                    }
                    else
                    {
                        SteamVR_Action_Pose   cameraPose   = SteamVR_Settings.instance.mixedRealityCameraPose;
                        SteamVR_Input_Sources cameraSource = SteamVR_Settings.instance.mixedRealityCameraInputSource;

                        if (cameraPose != null && SteamVR_Settings.instance.mixedRealityActionSetAutoEnable)
                        {
                            if (cameraPose.actionSet != null && cameraPose.actionSet.IsActive(cameraSource) == false)
                            {
                                cameraPose.actionSet.Activate(cameraSource);
                            }
                        }

                        if (cameraPose == null)
                        {
                            doesPathExist = false;
                            return(false);
                        }

                        if (cameraPose != null && cameraPose[cameraSource].active && cameraPose[cameraSource].deviceIsConnected)
                        {
                            GameObject instance = Instantiate(prefab);
                            instance.gameObject.name = "External Camera";

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

            return(externalCamera != null);
        }