Exemplo n.º 1
0
  public void LaunchVrHome() {
#if UNITY_ANDROID && !UNITY_EDITOR
    GvrDaydreamApi.LaunchVrHomeAsync((success) => {
      if (!success) {
        // Unexpected. See GvrDaydreamApi log messages for details.
        Debug.LogError("GvrDaydreamApi.LaunchVrHomeAsync() failed");
      }
    });
#endif  // UNITY_ANDROID && !UNITY_EDITOR
  }
Exemplo n.º 2
0
    IEnumerator _FinalSequence()
    {
        yield return(new WaitForSeconds(blackFadeOutTime));

        Debug.Log("Starting final sequence");

        GvrDaydreamApi.LaunchVrHome();
        yield return(new WaitForSeconds(0.5f));

        Application.Quit();
    }
Exemplo n.º 3
0
    void Start()
    {
#if !UNITY_HAS_GOOGLEVR || !UNITY_ANDROID || UNITY_EDITOR
        if (m_launchVrHomeButton == null)
        {
            return;
        }
        m_launchVrHomeButton.SetActive(false);
#else
        GvrDaydreamApi.Create();
#endif  // !UNITY_HAS_GOOGLEVR || !UNITY_ANDROID || UNITY_EDITOR
    }
Exemplo n.º 4
0
    /// Asynchronously instantiates a GvrDayreamApi.
    ///
    /// The provided callback will be called with a bool argument indicating
    /// whether instance creation was successful.
    public static void CreateAsync(Action <bool> callback)
    {
        if (m_instance == null)
        {
            m_instance = new GvrDaydreamApi();
        }
#if UNITY_ANDROID && !UNITY_EDITOR
        if (m_instance.m_daydreamApiObject != null)
        {
            return;
        }

        if (m_instance.m_daydreamApiClass == null)
        {
            Debug.LogErrorFormat("Failed to get DaydreamApi class, {0}", PACKAGE_DAYDREAM_API);
            return;
        }

        AndroidJavaObject activity = GvrActivityHelper.GetActivity();
        if (activity == null)
        {
            Debug.LogError("DaydreamApi.Create failed to get acitivty");
            return;
        }

        AndroidJavaObject context = GvrActivityHelper.GetApplicationContext(activity);
        if (context == null)
        {
            Debug.LogError("DaydreamApi.Create failed to get application context from activity");
            return;
        }

        activity.Call(METHOD_RUN_ON_UI_THREAD, new AndroidJavaRunnable(() =>
        {
            m_instance.m_daydreamApiObject =
                m_instance.m_daydreamApiClass.CallStatic <AndroidJavaObject>(METHOD_CREATE, context);
            bool success = m_instance.m_daydreamApiObject != null;
            if (!success)
            {
                Debug.LogErrorFormat("DaydreamApi.Create call to {0} failed to instantiate object",
                                     METHOD_CREATE);
            }

            if (callback != null)
            {
                callback(success);
            }
        }));
#endif  // UNITY_ANDROID && !UNITY_EDITOR
    }
Exemplo n.º 5
0
  void Start() {
#if !UNITY_ANDROID || UNITY_EDITOR
    if (m_launchVrHomeButton == null) {
      return;
    }
    m_launchVrHomeButton.SetActive(false);
#else
    GvrDaydreamApi.CreateAsync((success) => {
      if (!success) {
        // Unexpected. See GvrDaydreamApi log messages for details.
        Debug.LogError("GvrDaydreamApi.CreateAsync() failed");
      }
    });
#endif  // !UNITY_ANDROID || UNITY_EDITOR
  }
Exemplo n.º 6
0
    public void quitApp(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
    {
        if (!initialize)
        {
            switch (SelectController.getActivePlatform())
            {
            case SelectController.DeviceOptions.Daydream:
                GvrDaydreamApi.LaunchVrHomeAsync(null);
                break;

            default:
                Application.Quit();
#if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
#endif
                break;
            }
        }
    }
    /// #endcond

    /// Instantiates a GvrDayreamApi.
    public static void Create()
    {
        if (m_instance == null)
        {
            m_instance = new GvrDaydreamApi();
        }
#if !UNITY_EDITOR && UNITY_HAS_GOOGLEVR && UNITY_ANDROID
        if (m_instance.m_daydreamApiObject != null)
        {
            return;
        }

        if (m_instance.m_daydreamApiClass == null)
        {
            Debug.LogErrorFormat("Failed to get DaydreamApi class, {0}", PACKAGE_DAYDREAM_API);
            return;
        }

        AndroidJavaObject activity = GvrActivityHelper.GetActivity();
        if (activity == null)
        {
            return;
        }

        AndroidJavaObject context = GvrActivityHelper.GetApplicationContext(activity);
        if (context == null)
        {
            return;
        }

        activity.Call(METHOD_RUN_ON_UI_THREAD, new AndroidJavaRunnable(() => {
            m_instance.m_daydreamApiObject =
                m_instance.m_daydreamApiClass.CallStatic <AndroidJavaObject>(METHOD_CREATE, context);
            if (m_instance.m_daydreamApiObject == null)
            {
                Debug.LogError("DaydreamApi.Create failed to instantiate object");
            }
        })
                      );
#endif  // !UNITY_EDITOR && UNITY_HAS_GOOGLEVR && UNITY_ANDROID
    }
Exemplo n.º 8
0
    void Start()
    {
        Input.backButtonLeavesApp = true;
        startingPosition          = transform.localPosition;

                #if !UNITY_ANDROID || UNITY_EDITOR
        if (m_launchVrHomeButton == null)
        {
            return;
        }
        m_launchVrHomeButton.SetActive(false);
                #else
        GvrDaydreamApi.CreateAsync((success) => {
            if (!success)
            {
                // Unexpected. See GvrDaydreamApi log messages for details.
                Debug.LogError("GvrDaydreamApi.CreateAsync() failed");
            }
        });
                #endif  // !UNITY_ANDROID || UNITY_EDITOR
    }
Exemplo n.º 9
0
 /// @cond
 /// Call Dispose to free up memory used by this API.
 public void Dispose()
 {
     m_instance = null;
 }
Exemplo n.º 10
0
    public void LaunchVrHome()
    {
#if UNITY_HAS_GOOGLEVR && UNITY_ANDROID && !UNITY_EDITOR
        GvrDaydreamApi.LaunchVrHome();
#endif  // UNITY_HAS_GOOGLEVR && UNITY_ANDROID && !UNITY_EDITOR
    }