Exemple #1
0
        } //END Awake

        //-----------------------//
        public virtual void DestroyIfIncompatibleXRTechnology()
        //-----------------------//
        {
            bool destroy = false;

            if( GameObject.FindObjectOfType<XRTechnologyManager>() != null )
            {
                XRTechnologyManager xrTechnologyManager = GameObject.FindObjectOfType<XRTechnologyManager>();

                if( xrTechnologyManager.xrTechnologyType == XRTechnologyManager.XRTechnologyType.None ||
                    !GetXRTechnologyType().Contains( xrTechnologyManager.xrTechnologyType ) )
                {
                    destroy = true;
                }
            }
            else
            {
                destroy = true;
            }

            if( destroy )
            {
#if UNITY_EDITOR
                //Wait a moment before calling DestroyImmediate to make sure no logic is running
                UnityEditor.EditorApplication.delayCall += () =>
                {
                    DestroyImmediate( gameObject );
                };
#else
                Destroy( gameObject );
#endif
            }

        } //END DestroyIfIncompatibleXRTechnology
Exemple #2
0
        } //END CreateCamera

        //----------------------------------------//
        private GameObject GetCameraPrefab()
        //----------------------------------------//
        {
            //Default to a standard 2D camera
            GameObject cameraPrefab = _2DCamera;

            //Use the XRTechnologyManager to determine what camera type to use
            if( GameObject.FindObjectOfType<XRTechnologyManager>() != null )
            {
                XRTechnologyManager xrTechnologyManager = GameObject.FindObjectOfType<XRTechnologyManager>();

                if( xrTechnologyManager.xrTechnologyType == XRTechnologyManager.XRTechnologyType.None )
                {
                    //If the user chooses to use the Stereo 3D camera, use that instead of the 2D camera
                    if( cameraType == BasicCameraType.stereoThreeDimensionalCamera )
                    {
                        cameraPrefab = _Stereo3DCamera;
                    }
                }
                else if( xrTechnologyManager.xrTechnologyType == XRTechnologyManager.XRTechnologyType.Vuforia ||
                         xrTechnologyManager.xrTechnologyType == XRTechnologyManager.XRTechnologyType.VuforiaFusion )
                {
#if VUFORIA
                    if( _vuforiaCamera != null )
                    {
                        cameraPrefab = _vuforiaCamera;
                    }
                    else
                    {
#if UNITY_EDITOR
                        cameraPrefab = (GameObject)AssetDatabase.LoadAssetAtPath( "Assets/BrandXR/Prefabs/Cameras/bxr_VuforiaCamera.prefab", typeof( GameObject ) );
#endif
                    }
#else
                    cameraPrefab = _2DCamera;
#endif
                }
                else if( xrTechnologyManager.xrTechnologyType == XRTechnologyManager.XRTechnologyType.ARCore ||
                         xrTechnologyManager.xrTechnologyType == XRTechnologyManager.XRTechnologyType.ARKit ||
                         xrTechnologyManager.xrTechnologyType == XRTechnologyManager.XRTechnologyType.ARCore_ARKit )
                {
                    if( arCameraType == ARCoreAndARKitCameraType.twoDimensionalCamera )
                    {
                        cameraPrefab = _2DCamera;
                    }
                }
            }

            return cameraPrefab;

        } //END GetCameraPrefab
        } //END Awake

        //--------------------------------------------//
        private void DestroyDuplicateInstance()
        //--------------------------------------------//
        {

            //Ensure only one instance exists
            if( _instance == null )
            {
                _instance = this;
            }
            else if( this != _instance )
            {
                Destroy( this.gameObject );
            }

        } //END DestroyDuplicateInstance
Exemple #4
0
        } //END OnPreprocessBuild

        //------------------------------------//
        private void CheckForIncompatibleXRTargets()
        //------------------------------------//
        {
            //Grab the XRTechnologyManager
            if (GameObject.FindObjectOfType <XRTechnologyManager>() != null)
            {
                XRTechnologyManager xrTechnologyManager = GameObject.FindObjectOfType <XRTechnologyManager>();

                //If our XR tech is set to none, then any XRTargetBase prefabs and their children will be removed
                if (xrTechnologyManager.xrTechnologyType == XRTechnologyManager.XRTechnologyType.None)
                {
                    RemoveAllXRTargetBases();
                }

                //Otherwise, remove all XRTargetBase prefabs that do not match the selected technology
                else
                {
                    RemoveAllXRTargetBases(xrTechnologyManager.xrTechnologyType);
                }
            }
        } //END CheckForIncompatibleXRTargets