Exemplo n.º 1
0
        internal AndroidNativeControllerProvider(bool enableGyro, bool enableAccel)
        {
            Debug.Log("Initializing GVR Controller API.");

            options = new gvr_controller_api_options();
            gvr_controller_init_default_options(ref options);
            options.enable_accel = enableAccel ? (byte)1 : (byte)0;
            options.enable_gyro  = enableGyro ? (byte)1 : (byte)0;

            // Get a hold of the activity, context and class loader.
            AndroidJavaObject activity = GetActivity();

            if (activity == null)
            {
                error        = true;
                errorDetails = "Failed to get Activity from Unity Player.";
                return;
            }
            androidContext = GetApplicationContext(activity);
            if (androidContext == null)
            {
                error        = true;
                errorDetails = "Failed to get Android application context from Activity.";
                return;
            }
            classLoader = GetClassLoaderFromActivity(activity);
            if (classLoader == null)
            {
                error        = true;
                errorDetails = "Failed to get class loader from Activity.";
                return;
            }

            Debug.Log("Creating and initializing GVR API controller object.");
            api = gvr_controller_create_and_init_android(IntPtr.Zero, androidContext.GetRawObject(),
                                                         classLoader.GetRawObject(), ref options, IntPtr.Zero);
            if (IntPtr.Zero == api)
            {
                Debug.LogError("Error creating/initializing GVR Controller API.");
                error        = true;
                errorDetails = "Failed to initialize GVR Controller API.";
                return;
            }
            Debug.Log("GVR API successfully initialized. Now resuming it.");
            gvr_controller_resume(api);
            Debug.Log("GVR API resumed.");
        }
        internal AndroidNativeControllerProvider(bool enableGyro, bool enableAccel)
        {
            Debug.Log("Initializing Daydream controller API.");

              options = new gvr_controller_api_options();
              gvr_controller_init_default_options(ref options);
              options.enable_accel = enableAccel ? (byte) 1 : (byte) 0;
              options.enable_gyro = enableGyro ? (byte) 1 : (byte) 0;

              // Get a hold of the activity, context and class loader.
              AndroidJavaObject activity = GetActivity();
              if (activity == null) {
            error = true;
            errorDetails = "Failed to get Activity from Unity Player.";
            return;
              }
              androidContext = GetApplicationContext(activity);
              if (androidContext == null) {
            error = true;
            errorDetails = "Failed to get Android application context from Activity.";
            return;
              }
              classLoader = GetClassLoaderFromActivity(activity);
              if (classLoader == null) {
            error = true;
            errorDetails = "Failed to get class loader from Activity.";
            return;
              }

              Debug.Log("Creating and initializing GVR API controller object.");
              api = gvr_controller_create_and_init_android(IntPtr.Zero, androidContext.GetRawObject(),
              classLoader.GetRawObject(), ref options, IntPtr.Zero);
              if (IntPtr.Zero == api) {
            Debug.LogError("Error creating/initializing Daydream controller API.");
            error = true;
            errorDetails = "Failed to initialize Daydream controller API.";
            return;
              }
              Debug.Log("GVR API successfully initialized. Now resuming it.");
              gvr_controller_resume(api);
              Debug.Log("GVR API resumed.");
        }
 private static extern void gvr_controller_init_default_options(
 ref gvr_controller_api_options options);
 private static extern IntPtr gvr_controller_create_and_init_android(
 IntPtr jniEnv, IntPtr androidContext, IntPtr classLoader,
 ref gvr_controller_api_options options, IntPtr context);
Exemplo n.º 5
0
 private static extern IntPtr gvr_controller_create_and_init_android(
     IntPtr jniEnv, IntPtr androidContext, IntPtr classLoader,
     ref gvr_controller_api_options options, IntPtr context);
Exemplo n.º 6
0
 private static extern void gvr_controller_init_default_options(
     ref gvr_controller_api_options options);