Пример #1
0
    // Use this for initialization
    void Start()
    {
        lastRot = cam.rotation;

        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += HandleTouchHandler;
    }
Пример #2
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        Debug.Log("Unity v" + Application.unityVersion + ", " +
                  "Oculus Utilities v" + OVRPlugin.wrapperVersion + ", " +
                  "OVRPlugin v" + OVRPlugin.version + ", " +
                  "SDK v" + OVRPlugin.nativeSDKVersion + ".");

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        var supportedTypes =
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D11.ToString() + ", " +
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D12.ToString();

        if (!supportedTypes.Contains(SystemInfo.graphicsDeviceType.ToString()))
        {
            Debug.LogWarning("VR rendering requires one of the following device types: (" + supportedTypes + "). Your graphics device: " + SystemInfo.graphicsDeviceType.ToString());
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

        Initialize();

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

        // Disable the occlusion mesh by default until open issues with the preview window are resolved.
        OVRPlugin.occlusionMesh = false;
    }
 void Start()
 {
     OVRTouchpad.Create();
     OVRTouchpad.TouchHandler += HandleTouchHandler;
     lights   = FindObjectOfType <LightsOut>();
     charMove = GetComponent <CharacterMovement1>();
 }
Пример #4
0
 void OnEnable()
 {
     OVRTouchpad.Create();
     OVRTouchpad.TouchHandler += GearTouchHandler;
     lobbyManager              = GameObject.Find("GameManager").GetComponent <LobbyManager> ();
     lobbyManager.OnTapObject += OnTapObject;
 }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        float ypos = -0.72f;

        cams = new Vector3[5];

        cams[0] = new Vector3(-0.26f, ypos, 5.6f);
        cams[1] = new Vector3(-2.85f, ypos, -25.2f);
        cams[2] = new Vector3(-3.61f, ypos, 13.7f);
        cams[3] = new Vector3(13.75f, ypos, 13.7f);
        cams[4] = new Vector3(3.5f, ypos, 24.4f);

        rots = new Quaternion[5];

        rots [0] = new Quaternion();
        rots [1] = new Quaternion();
        rots [2] = new Quaternion();
        rots [3] = new Quaternion();
        rots [4] = new Quaternion();



        rots[0] = Quaternion.Euler(new Vector3(0, 147, 0));
        rots[1] = Quaternion.Euler(new Vector3(0, 0, 0));
        rots[2] = Quaternion.Euler(new Vector3(0, 176, 0));
        rots[3] = Quaternion.Euler(new Vector3(0, 242, 0));
        rots[4] = Quaternion.Euler(new Vector3(0, 320, 0));

        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += HandleTouchHandler;
    }
    // * * * * * * * * * * * * *
    // MonoBehaviour overrides

    /// <summary>
    /// Awake this instance.
    /// </summary>
    void Awake()
    {
        // We can only have one instance of OVRLipSync in a scene (use this for local property query)
        if (sInstance == null)
        {
            sInstance = this;
        }
        else
        {
            Debug.LogWarning(System.String.Format("OVRLipSync Awake: Only one instance of OVRPLipSync can exist in the scene."));
            return;
        }

        if (IsInitialized() != Result.Success)
        {
            sInitialized = Initialize();

            if (sInitialized != Result.Success)
            {
                Debug.LogWarning(System.String.Format
                                     ("OvrLipSync Awake: Failed to init Speech Rec library"));
            }
        }

        // Important: Use the touchpad mechanism for input, call Create on the OVRTouchpad helper class
        OVRTouchpad.Create();
    }
Пример #7
0
#pragma warning restore 414             // The private field 'x' is assigned but its value is never used

    // * * * * * * * * * * * * *

    /// <summary>
    /// Awake this instance.
    /// </summary>
    void Awake()
    {
        // Init
        theDevice = this;
        OVRInit   = OVR_Initialize();
        if (OVRInit == false)
        {
            return;
        }

#if (UNITY_ANDROID && !UNITY_EDITOR)
        // Don't allow the application to run if it's not in landscape left.
        if (Screen.orientation != ScreenOrientation.LandscapeLeft)
        {
            // make the error nice and big so you can see it in logcat or in the Unity Editor
            Debug.LogError("**************************************************************************************************************\n" +
                           "**************************************************************************************************************\n");
            Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
                           "***** Stopping application.\n");
            Debug.LogError("**************************************************************************************************************\n" +
                           "**************************************************************************************************************");

            Debug.Break();
            Application.Quit();
        }
#endif

#if (UNITY_ANDROID && !UNITY_EDITOR)
        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();
#endif

        // Set initial prediction time
        SetPredictionTime(PredictionTime);
    }
Пример #8
0
    void OnEnable()
    {
        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += GearTouchHandler;

        MultiSelectBoard.SetActive(false);
    }
Пример #9
0
    // Use this for initialization
    void Start()
    {
        // Create the GearVR touch handler
        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += HandleTouchHandler;

        // Get the camera in the scene
        camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
    }
Пример #10
0
 void Update()
 {
     OVRTouchpad.Update();
     if (!UIdata.isHaveCamera)
     {
         camera = GameObject.Find("Main Camera");
         UIdata.isHaveCamera = true;
     }
 }
    // Use this for initialization
    void Start()
    {
        // Add a listener to the OVRTouchpad for touch events
        OVRTouchpad.AddListener(LocalTouchEventCallback);

        // Initialize the proper target set
        targetSet = 0;
        SwitchTargets[0].SetActive <OVRLipSyncContextMorphTarget>(0);
        SwitchTargets[1].SetActive <OVRLipSyncContextMorphTarget>(0);
    }
Пример #12
0
    private void Start()
    {
        m_clampValueMin         = new Vector3(-450, 0, -600);
        m_clampValueMax         = new Vector3(350, 0, 600);
        initialDis              = m_mainCam.position - m_transform.position;
        m_rigidbody.isKinematic = true;

        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += HandleTouchHandler;
    }
Пример #13
0
    // Use this for initialization
    void Start()
    {
        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += UpdateInput;
        _playerActions            = GetComponent <PlayerActions>();

        Cursor.visible = false;

        Debug.Log("InputManagerStarted");
    }
Пример #14
0
 private static void HandleInputMouse(ref Vector3 move)
 {
     if (move.magnitude < OVRTouchpad.minMovMagnitudeMouse)
     {
         if (OVRTouchpad.TouchHandler != null)
         {
             OVRTouchpad.TouchHandler(null, new OVRTouchpad.TouchArgs
             {
                 TouchType = OVRTouchpad.TouchEvent.SingleTap
             });
         }
     }
     else
     {
         move.Normalize();
         if (Mathf.Abs(move.x) > Mathf.Abs(move.y))
         {
             if (move.x > 0f)
             {
                 if (OVRTouchpad.TouchHandler != null)
                 {
                     OVRTouchpad.TouchHandler(null, new OVRTouchpad.TouchArgs
                     {
                         TouchType = OVRTouchpad.TouchEvent.Left
                     });
                 }
             }
             else if (OVRTouchpad.TouchHandler != null)
             {
                 OVRTouchpad.TouchHandler(null, new OVRTouchpad.TouchArgs
                 {
                     TouchType = OVRTouchpad.TouchEvent.Right
                 });
             }
         }
         else if (move.y > 0f)
         {
             if (OVRTouchpad.TouchHandler != null)
             {
                 OVRTouchpad.TouchHandler(null, new OVRTouchpad.TouchArgs
                 {
                     TouchType = OVRTouchpad.TouchEvent.Down
                 });
             }
         }
         else if (OVRTouchpad.TouchHandler != null)
         {
             OVRTouchpad.TouchHandler(null, new OVRTouchpad.TouchArgs
             {
                 TouchType = OVRTouchpad.TouchEvent.Up
             });
         }
     }
 }
Пример #15
0
 public static void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         OVRTouchpad.moveAmountMouse = Input.mousePosition;
         OVRTouchpad.touchState      = OVRTouchpad.TouchState.Down;
     }
     else if (Input.GetMouseButtonUp(0))
     {
         OVRTouchpad.moveAmountMouse -= Input.mousePosition;
         OVRTouchpad.HandleInputMouse(ref OVRTouchpad.moveAmountMouse);
         OVRTouchpad.touchState = OVRTouchpad.TouchState.Init;
     }
 }
Пример #16
0
    // * * * * * * * * * * * * *
    // Private members

    /// <summary>
    /// Start this instance.
    /// Note: make sure to always have a Start function for classes that have editor scripts.
    /// </summary>
    void Start()
    {
        // Add a listener to the OVRTouchpad for touch events
        if (enableTouchInput)
        {
            OVRTouchpad.AddListener(LocalTouchEventCallback);
        }

        // Find console
        OVRLipSyncDebugConsole[] consoles = FindObjectsOfType <OVRLipSyncDebugConsole>();
        if (consoles.Length > 0)
        {
            hasDebugConsole = consoles[0];
        }
    }
Пример #17
0
    void Start()
    {
        // 기존 화면에 있던 오브젝트 비활성화
        prefab_bullt_.SetActive(false);

        // 유니티 화면이 꺼지지 않게 설정
#if UNITY_ANDROID
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
#elif UNITY_IOS
        iPhoneSettings.screenCanDarken = false;
#endif

        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += HandleTouchHandler;
    }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        cams     = new Camera[5];
        cams [0] = cam1;
        cams [1] = cam2;
        cams [2] = cam3;
        cams [3] = cam4;
        cams [4] = cam5;

        foreach (Camera c in cams)
        {
            c.enabled = false;
        }
        cams[activeCam].enabled = true;

        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += HandleTouchHandler;
    }
Пример #19
0
 public override void InstanceInitiate(StateMachine checkMachine)
 {
     InputMachine.instance = this;
     if (thisCamera == null)
     {
         thisCamera = GetComponent <Camera> ();
     }
     OVRTouchpad.Create();
     swipeUp      = StateMaster.instance.inputUI;
     swipeDown    = StateMaster.instance.inputInteract;
     swipeForward = StateMaster.instance.inputTeleport;
     swipeBack    = StateMaster.instance.inputInteract;
     UpdateState(StateMaster.instance.inputTeleport, this);
     EventSystem.current.sendNavigationEvents = false;
     thisCamera.layerCullSpherical            = true;
     Application.targetFrameRate = 240;
     HOTween.To(blackoutDip, 5f, new TweenParms().Prop("color", new Color(0f, 0f, 0f, 0f)));
     StartCoroutine("InitialCheckObjects");
 }
Пример #20
0
 // Token: 0x06003A86 RID: 14982 RVA: 0x00127500 File Offset: 0x00125900
 private void Awake()
 {
     if (OVRLipSync.sInstance == null)
     {
         OVRLipSync.sInstance = this;
         int outputSampleRate = AudioSettings.outputSampleRate;
         int num;
         int num2;
         AudioSettings.GetDSPBufferSize(out num, out num2);
         string message = string.Format("OvrLipSync Awake: Queried SampleRate: {0:F0} BufferSize: {1:F0}", outputSampleRate, num);
         Debug.LogWarning(message);
         OVRLipSync.sOVRLipSyncInit = OVRLipSync.ovrLipSyncDll_Initialize(outputSampleRate, num);
         if (OVRLipSync.sOVRLipSyncInit != 0)
         {
             Debug.LogWarning(string.Format("OvrLipSync Awake: Failed to init Speech Rec library", new object[0]));
         }
         OVRTouchpad.Create();
         return;
     }
     Debug.LogWarning(string.Format("OVRLipSync Awake: Only one instance of OVRPLipSync can exist in the scene.", new object[0]));
 }
Пример #21
0
    // * * * * * * * * * * * * *
    // MonoBehaviour overrides

    /// <summary>
    /// Awake this instance.
    /// </summary>
    void Awake()
    {
        // We can only have one instance of OVRLipSync in a scene (use this for local property query)
        if (sInstance == null)
        {
            sInstance = this;
        }
        else
        {
            Debug.LogWarning(System.String.Format("OVRVoiceMod Awake: Only one instance of OVRVoiceMod can exist in the scene."));
            return;
        }

        int samplerate;
        int bufsize;
        int numbuf;

        // Get the current sample rate
        samplerate = AudioSettings.outputSampleRate;
        // Get the current buffer size and number of buffers
        AudioSettings.GetDSPBufferSize(out bufsize, out numbuf);

        String str = System.String.Format
                         ("OvrVoiceMod Awake: Queried SampleRate: {0:F0} BufferSize: {1:F0}", samplerate, bufsize);

        Debug.LogWarning(str);

        sOVRVoiceModInit = ovrVoiceModDll_Initialize(samplerate, bufsize);

        if (sOVRVoiceModInit != ovrVoiceModSuccess)
        {
            Debug.LogWarning(System.String.Format
                                 ("OvrVoiceMod Awake: Failed to init VoiceMod library"));
        }

        // Important: Use the touchpad mechanism for input, call Create on the OVRTouchpad helper class
        OVRTouchpad.Create();
    }
Пример #22
0
    /// <summary>
    /// Awake this instance.
    /// </summary>
    void Awake()
    {
        OVRTouchpad.Update();         //后添加的
        // Find camera controller
        OVRCameraRig[] cameraControllers;
        cameraControllers = gameObject.GetComponentsInChildren <OVRCameraRig>();

        if (cameraControllers.Length == 0)
        {
            Debug.LogWarning("OVRMainMenu: No OVRCameraRig attached.");
        }
        else if (cameraControllers.Length > 1)
        {
            Debug.LogWarning("OVRMainMenu: More then 1 OVRCameraRig attached.");
        }
        else
        {
            cameraController = cameraControllers[0];
        }

        // Find player controller
        OVRPlayerController[] playerControllers;
        playerControllers = gameObject.GetComponentsInChildren <OVRPlayerController>();

        if (playerControllers.Length == 0)
        {
            Debug.LogWarning("OVRMainMenu: No OVRPlayerController attached.");
        }
        else if (playerControllers.Length > 1)
        {
            Debug.LogWarning("OVRMainMenu: More then 1 OVRPlayerController attached.");
        }
        else
        {
            playerController = playerControllers[0];
        }
    }
Пример #23
0
    // Use this for initialization
    void Start()
    {
        StartCoroutine(startVideoFeed());

        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += HandleTouchHandler;

        /* // on start
         * Debug.Log("Sending position");
         *
         * HTTPRequest request = new HTTPRequest(new Uri("http://api-m2x.att.com/v2/devices/8e8402aaa6c97bc7e2f9d5bd6a454fa2/streams/position/value"), HTTPMethods.Put, callback);
         *
         * JSONClass data = new JSONClass();
         *
         * data["value"] = ;
         *
         * request.AddHeader("X-M2X-KEY", "9fc7996ea7f03fccc6ef3978f2a4d012");
         * request.AddHeader("Content-Type", "application/json");
         *
         * request.RawData = Encoding.UTF8.GetBytes(data.ToString());
         * request.Send();
         *
         * Debug.Log("Sent");*/
    }
Пример #24
0
 public void OnDisable()
 {
     OVRTouchpad.OnDisable();
 }
Пример #25
0
 void Update()
 {
     OVRTouchpad.Update();
 }
Пример #26
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        System.Version netVersion = OVRPlugin.wrapperVersion;
        System.Version ovrVersion = OVRPlugin.version;

        //Debug.Log("Unity v" + Application.unityVersion + ", " +
        //          "Oculus Utilities v" + netVersion + ", " +
        //          "OVRPlugin v" + ovrVersion + ".");

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Direct3D11)
        {
            Debug.LogWarning("VR rendering requires Direct3D11. Your graphics device: " + SystemInfo.graphicsDeviceType);
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

        InitVolumeController();

        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }
        if (input == null)
        {
            input = new OVRInput();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }
    }
Пример #27
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        Debug.Log("Unity v" + Application.unityVersion + ", " +
                  "Oculus Utilities v" + OVRPlugin.wrapperVersion + ", " +
                  "OVRPlugin v" + OVRPlugin.version + ", " +
                  "SDK v" + OVRPlugin.nativeSDKVersion + ".");

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        var supportedTypes =
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D11.ToString() + ", " +
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D12.ToString();

        if (!supportedTypes.Contains(SystemInfo.graphicsDeviceType.ToString()))
        {
            Debug.LogWarning("VR rendering requires one of the following device types: (" + supportedTypes + "). Your graphics device: " + SystemInfo.graphicsDeviceType.ToString());
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

#if !UNITY_EDITOR
        enableMixedReality = false;                     // we should never start the standalone game in MxR mode, unless the command-line parameter is provided
#endif

        if (MixedRealityEnabledFromCmd())
        {
            Debug.Log("OVR: Mixed Reality mode enabled");
            enableMixedReality = true;
        }

        if (enableMixedReality)
        {
            if (UseDirectCompositionFromCmd())
            {
                useDirectComposition = true;
            }
            if (UseExternalCompositionFromCmd())
            {
                useDirectComposition = false;
            }
            Debug.Log("OVR: Direct Composition " + (useDirectComposition ? "on" : "off"));
        }

        Initialize();

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

        // Disable the occlusion mesh by default until open issues with the preview window are resolved.
        OVRPlugin.occlusionMesh = false;

#if UNITY_EDITOR
        EditorApplication.playmodeStateChanged += OnEditorApplicationPlaymodeStateChanged;
#endif
    }
Пример #28
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

                #if !UNITY_ANDROID || UNITY_EDITOR
        if (!ovrIsInitialized)
        {
            OVR_Initialize();
            OVRPluginEvent.Issue(RenderEventType.Initialize);

            ovrIsInitialized = true;
        }

        var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
        var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString());
        if (netVersion > ovrVersion)
        {
            Debug.LogWarning("Using an older version of LibOVR.");
        }
                #endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

                #if UNITY_ANDROID && !UNITY_EDITOR
        // don't allow the application to run if orientation is not landscape left.
        if (Screen.orientation != ScreenOrientation.LandscapeLeft)
        {
            Debug.LogError("********************************************************************************\n");
            Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
                           "***** Stopping application.\n");
            Debug.LogError("********************************************************************************\n");

            Debug.Break();
            Application.Quit();
        }

        // don't enable gyro, it is not used and triggers expensive display calls
        if (Input.gyro.enabled)
        {
            Debug.LogError("*** Auto-disabling Gyroscope ***");
            Input.gyro.enabled = false;
        }

        // NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
        // main window surface with front buffer rendering enabled. The view will
        // render black.
        // On Adreno KitKat, some tiling control modes will cause the view to render
        // black.
        if (QualitySettings.antiAliasing > 1)
        {
            Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
        }

        // we sync in the TimeWarp, so we don't want unity
        // syncing elsewhere
        QualitySettings.vSyncCount = 0;

        // try to render at 60fps
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity            = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());

                        #if !INHIBIT_ENTITLEMENT_CHECK
            AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
            entitlementChecker.CallStatic("doAutomatedCheck", activity);
                        #else
            Debug.Log("Inhibiting Entitlement Check!");
                        #endif

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        InitVolumeController();
                #else
        SetEditorPlay(Application.isEditor);
                #endif

        prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
        prevEyeTextureDepth        = OVRManager.instance.eyeTextureDepth;
        prevEyeTextureFormat       = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale     = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale    = OVRManager.instance.virtualTextureScale;
        prevMonoscopic             = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

                #if !UNITY_ANDROID || UNITY_EDITOR
        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
        }
                #endif

                #if (UNITY_STANDALONE_WIN && (UNITY_4_6 || UNITY_4_5))
        bool unity_4_6   = false;
        bool unity_4_5_2 = false;
        bool unity_4_5_3 = false;
        bool unity_4_5_4 = false;
        bool unity_4_5_5 = false;

                #if (UNITY_4_6)
        unity_4_6 = true;
                #elif (UNITY_4_5_2)
        unity_4_5_2 = true;
                #elif (UNITY_4_5_3)
        unity_4_5_3 = true;
                #elif (UNITY_4_5_4)
        unity_4_5_4 = true;
                #elif (UNITY_4_5_5)
        unity_4_5_5 = true;
                #endif

        // Detect correct Unity releases which contain the fix for D3D11 exclusive mode.
        string version = Application.unityVersion;
        int    releaseNumber;
        bool   releaseNumberFound = Int32.TryParse(Regex.Match(version, @"\d+$").Value, out releaseNumber);

        // Exclusive mode was broken for D3D9 in Unity 4.5.2p2 - 4.5.4 and 4.6 builds prior to beta 21
        bool unsupportedExclusiveModeD3D9 = (unity_4_6 && version.Last(char.IsLetter) == 'b' && releaseNumberFound && releaseNumber < 21) ||
                                            (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) ||
                                            (unity_4_5_3) ||
                                            (unity_4_5_4);

        // Exclusive mode was broken for D3D11 in Unity 4.5.2p2 - 4.5.5p2 and 4.6 builds prior to f1
        bool unsupportedExclusiveModeD3D11 = (unity_4_6 && version.Last(char.IsLetter) == 'b') ||
                                             (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) ||
                                             (unity_4_5_3) ||
                                             (unity_4_5_4) ||
                                             (unity_4_5_5 && version.Last(char.IsLetter) == 'f') ||
                                             (unity_4_5_5 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber < 3);

        if (unsupportedExclusiveModeD3D9 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
        {
            MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }

        if (unsupportedExclusiveModeD3D11 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
        {
            MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }
                #endif
    }
Пример #29
0
 // Use this for initialization
 void Start()
 {
     QualitySettings.antiAliasing = 4;
     OVRTouchpad.Create();
     OVRTouchpad.TouchHandler += HandleTouchHandler;
 }
Пример #30
0
 // Use this for initialization
 void Start()
 {
     OVRTouchpad.Create();
     OVRTouchpad.TouchHandler += HandleTouchHandler;
     HideReticle();
 }