Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Commit

Permalink
GVR SDK for Unity v1.170.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rusmaxham committed Aug 30, 2018
1 parent 396e884 commit 5c97c6a
Show file tree
Hide file tree
Showing 58 changed files with 144 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ obj/
*.suo
*.userprefs

# Gradle generated
.gradle

# OS generated
.DS_Store
Binary file modified Assets/GoogleVR/Plugins/Android/exoplayer-r1.5.11.aar
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/Android/gvr-exoplayersupport-release.aar
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/Android/gvr-keyboardsupport-release.aar
Binary file not shown.
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/Android/gvr.aar
Binary file not shown.
5 changes: 3 additions & 2 deletions Assets/GoogleVR/Scripts/Cardboard/GvrReticlePointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/// Draws a circular reticle in front of any object that the user points at.
/// The circle dilates if the object is clickable.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrReticlePointer")]
public class GvrReticlePointer : GvrBasePointer {
/// The constants below are expsed for testing. Minimum inner angle of the reticle (in degrees).
public const float RETICLE_MIN_INNER_ANGLE = 0.0f;
Expand Down Expand Up @@ -112,9 +113,9 @@ public void UpdateDiameters() {
float outer_diameter = 2.0f * Mathf.Tan(outer_half_angle_radians);

ReticleInnerDiameter =
Mathf.Lerp(ReticleInnerDiameter, inner_diameter, Time.deltaTime * reticleGrowthSpeed);
Mathf.Lerp(ReticleInnerDiameter, inner_diameter, Time.unscaledDeltaTime * reticleGrowthSpeed);
ReticleOuterDiameter =
Mathf.Lerp(ReticleOuterDiameter, outer_diameter, Time.deltaTime * reticleGrowthSpeed);
Mathf.Lerp(ReticleOuterDiameter, outer_diameter, Time.unscaledDeltaTime * reticleGrowthSpeed);

MaterialComp.SetFloat("_InnerDiameter", ReticleInnerDiameter * ReticleDistanceInMeters);
MaterialComp.SetFloat("_OuterDiameter", ReticleOuterDiameter * ReticleDistanceInMeters);
Expand Down
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/Controller/ArmModel/GvrArmModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/// Standard implementation for a mathematical model to make the virtual controller approximate the
/// physical location of the Daydream controller.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrArmModel")]
public class GvrArmModel : GvrBaseArmModel, IGvrControllerInputDeviceReceiver {
/// Position of the elbow joint relative to the head before the arm model is applied.
public Vector3 elbowRestPosition = DEFAULT_ELBOW_REST_POSITION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/// Interface for a mathematical model that uses the orientation and location
/// of the physical controller, and predicts the location of the controller and pointer
/// to determine where to place the controller model within the scene.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrBaseArmModel")]
public abstract class GvrBaseArmModel : MonoBehaviour {
/// Vector to represent the controller's location relative to
/// the user's head position.
Expand Down
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/Controller/GvrControllerInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public enum GvrControllerHand {
/// To access a controller's state, get a device from `GvrControllerInput.GetDevice` then
/// query it for state. For example, to the dominant controller's current orientation, use
/// `GvrControllerInput.GetDevice(GvrControllerHand.Dominant).Orientation`.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrControllerInput")]
public class GvrControllerInput : MonoBehaviour {
private static GvrControllerInputDevice[] instances = new GvrControllerInputDevice[0];
private static IControllerProvider controllerProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/// on distance from the camera.
[RequireComponent(typeof(MeshRenderer))]
[RequireComponent(typeof(MeshFilter))]
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrControllerReticleVisual")]
public class GvrControllerReticleVisual : MonoBehaviour {
[Serializable]
public struct FaceCameraData {
Expand Down
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/Controller/GvrControllerVisual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/// Provides visual feedback for the daydream controller.
[RequireComponent(typeof(Renderer))]
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrControllerVisual")]
public class GvrControllerVisual : MonoBehaviour, IGvrArmModelReceiver, IGvrControllerInputDeviceReceiver {
[System.Serializable]
public struct ControllerDisplayState {
Expand Down
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/Controller/GvrLaserPointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
/// The laser visual is important to help users locate their cursor
/// when its not directly in their field of view.
[RequireComponent(typeof(GvrLaserVisual))]
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrLaserPointer")]
public class GvrLaserPointer : GvrBasePointer {
[Tooltip("Distance from the pointer that raycast hits will be detected.")]
public float maxPointerDistance = 20.0f;
Expand Down
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/Controller/GvrLaserVisual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/// Provides functions for settings the end point of the laser,
/// and clamps the laser and reticle based on max distances.
[RequireComponent(typeof(LineRenderer))]
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrLaserVisual")]
public class GvrLaserVisual : MonoBehaviour, IGvrArmModelReceiver {
/// Used to position the reticle at the current position.
[Tooltip("Used to position the reticle at the current position.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
/// orientation change caused by the recenter event.
///
/// Usage: Place on the parent of the camera that should have it's orientation corrected.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrRecenterOnlyController")]
public class GvrRecenterOnlyController : MonoBehaviour {
private Quaternion lastAppliedYawCorrection = Quaternion.identity;
private Quaternion yawCorrection = Quaternion.identity;
Expand Down
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/Controller/GvrTrackedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
/// tracked, position of the object is updated to approximate arm mechanics by using a
/// `GvrBaseArmModel`. `GvrBaseArmModel`s are also propagated to all `IGvrArmModelReceiver`s
/// underneath this object.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrTrackedController")]
public class GvrTrackedController : MonoBehaviour {
[SerializeField]
[Tooltip("Arm model used to control the pose (position and rotation) of the object, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ class AndroidNativeControllerProvider : IControllerProvider {
private const int GVR_CONTROLLER_API_CLIENT_OBSOLETE = 5;
private const int GVR_CONTROLLER_API_MALFUNCTION = 6;

// The serialization of button-state used to determine which buttons are being pressed.
private readonly GvrControllerButton[] GVR_UNITY_BUTTONS = new GvrControllerButton[] {
GvrControllerButton.App,
GvrControllerButton.System,
GvrControllerButton.TouchPadButton,
GvrControllerButton.Reserved0,
GvrControllerButton.Reserved1,
GvrControllerButton.Reserved2
};
private readonly int[] GVR_BUTTONS = new int[] {
GVR_CONTROLLER_BUTTON_APP,
GVR_CONTROLLER_BUTTON_HOME,
GVR_CONTROLLER_BUTTON_CLICK,
GVR_CONTROLLER_BUTTON_RESERVED0,
GVR_CONTROLLER_BUTTON_RESERVED1,
GVR_CONTROLLER_BUTTON_RESERVED2
};

[StructLayout(LayoutKind.Sequential)]
private struct gvr_quat {
internal float x;
Expand Down Expand Up @@ -336,27 +354,10 @@ public void ReadState(ControllerState outState, int controller_id) {
gvr_vec2 touchPos = gvr_controller_state_get_touch_pos(statePtr);
outState.touchPos = new Vector2(touchPos.x, touchPos.y);

int[] gvr_buttons = new int[] {
GVR_CONTROLLER_BUTTON_APP,
GVR_CONTROLLER_BUTTON_HOME,
GVR_CONTROLLER_BUTTON_CLICK,
GVR_CONTROLLER_BUTTON_RESERVED0,
GVR_CONTROLLER_BUTTON_RESERVED1,
GVR_CONTROLLER_BUTTON_RESERVED2
};
GvrControllerButton[] gvrUnityButtons = new GvrControllerButton[] {
GvrControllerButton.App,
GvrControllerButton.System,
GvrControllerButton.TouchPadButton,
GvrControllerButton.Reserved0,
GvrControllerButton.Reserved1,
GvrControllerButton.Reserved2
};

outState.buttonsState = 0;
for (int i=0; i<gvr_buttons.Length; i++) {
if (0 != gvr_controller_state_get_button_state(statePtr, gvr_buttons[i])) {
outState.buttonsState |= gvrUnityButtons[i];
for (int i=0; i<GVR_BUTTONS.Length; i++) {
if (0 != gvr_controller_state_get_button_state(statePtr, GVR_BUTTONS[i])) {
outState.buttonsState |= GVR_UNITY_BUTTONS[i];
}
}
if (0 != gvr_controller_state_is_touching(statePtr)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/// A lightweight tooltip designed to minimize draw calls.
[ExecuteInEditMode]
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrControllerTooltipsSimple")]
public class GvrControllerTooltipsSimple : MonoBehaviour, IGvrArmModelReceiver {

private MeshRenderer tooltipRenderer;
Expand Down
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/Controller/Tooltips/GvrTooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
[RequireComponent(typeof(CanvasGroup))]
[RequireComponent(typeof(RectTransform))]
[ExecuteInEditMode]
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrTooltip")]
public class GvrTooltip : MonoBehaviour, IGvrArmModelReceiver {
/// Rotation for a tooltip when it is displayed on the right side of the controller visual.
protected static readonly Quaternion RIGHT_SIDE_ROTATION = Quaternion.Euler(0.0f, 0.0f, 0.0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/// View GvrBasePointerRaycaster.cs and GvrPointerInputModule.cs for more details.
[AddComponentMenu("GoogleVR/GvrPointerGraphicRaycaster")]
[RequireComponent(typeof(Canvas))]
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrPointerGraphicRaycaster")]
public class GvrPointerGraphicRaycaster : GvrBasePointerRaycaster {
public enum BlockingObjects {
None = 0,
Expand Down Expand Up @@ -135,13 +136,13 @@ protected override bool PerformRaycast(GvrBasePointer.PointerRay pointerRay, flo
float rayDot = Vector3.Dot(transForward, pointerRay.ray.direction);
resultDistance = transDot / rayDot;
Vector3 hitPosition = pointerRay.ray.origin + (pointerRay.ray.direction * resultDistance);
resultDistance = resultDistance + pointerRay.distanceFromStart;

// Check to see if the go is behind the camera.
if (resultDistance < 0 || resultDistance >= hitDistance || resultDistance > pointerRay.distance) {
continue;
}

resultDistance = resultDistance + pointerRay.distanceFromStart;
Transform pointerTransform =
GvrPointerInputModule.Pointer.PointerTransform;
float delta = (hitPosition - pointerTransform.position).magnitude;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
///
/// View GvrBasePointerRaycaster.cs and GvrPointerInputModule.cs for more details.
[AddComponentMenu("GoogleVR/GvrPointerPhysicsRaycaster")]
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrPointerPhysicsRaycaster")]
public class GvrPointerPhysicsRaycaster : GvrBasePointerRaycaster {
/// Used to sort the raycast hits by distance.
private class HitComparer: IComparer<RaycastHit> {
Expand Down
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/EventSystem/GvrScrollSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/// Used to override the global scroll settings in _GvrPointerScrollInput_
/// for the GameObject that this script is attached to.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrScrollSettings")]
public class GvrScrollSettings : MonoBehaviour, IGvrScrollSettings {
/// Override the Inertia property in _GvrPointerScrollInput_ for this object.
///
Expand Down
57 changes: 57 additions & 0 deletions Assets/GoogleVR/Scripts/EventSystem/GvrXREventsSubscriber.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2018 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using UnityEngine;
using System.Collections;

#if UNITY_2017_2_OR_NEWER
using UnityEngine.XR;
#else
using XRDevice = UnityEngine.VR.VRDevice;
using XRSettings = UnityEngine.VR.VRSettings;
#endif // UNITY_2017_2_OR_NEWER

// Handler for subscribing XR Unity actions to GVR Actions.
public class GvrXREventsSubscriber : MonoBehaviour {
private static GvrXREventsSubscriber instance;
private string _loadedDeviceName;
public static string loadedDeviceName {
get {
return GetInstance()._loadedDeviceName;
}
set {
GetInstance()._loadedDeviceName = value;
}
}

private static void OnDeviceLoadAction(string newLoadedDeviceName) {
loadedDeviceName = newLoadedDeviceName;
}

void Awake() {
instance = this;
_loadedDeviceName = XRSettings.loadedDeviceName;
#if UNITY_2018_3_OR_NEWER
XRDevice.deviceLoaded += OnDeviceLoadAction;
#endif // UNITY_2018_3_OR_NEWER
}

private static GvrXREventsSubscriber GetInstance() {
if (instance == null) {
GameObject gvrXREventsSubscriber = new GameObject("GvrXREventsSubscriber");
gvrXREventsSubscriber.AddComponent<GvrXREventsSubscriber>();
}
return instance;
}
}
11 changes: 11 additions & 0 deletions Assets/GoogleVR/Scripts/EventSystem/GvrXREventsSubscriber.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/// Exposes events from _GvrEventExecutor_ that are fired by _GvrPointerInputModule_ to the editor.
/// Makes it possible to handle EventSystem events globally.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrAllEventsTrigger")]
public class GvrAllEventsTrigger : MonoBehaviour {

[Serializable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
/// - Set the parent of GvrReticlePointer to the main camera.
///
[AddComponentMenu("GoogleVR/GvrPointerInputModule")]
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrPointerInputModule")]
public class GvrPointerInputModule : BaseInputModule, IGvrInputModuleController {
/// Determines whether Pointer input is active in VR Mode only (`true`), or all of the
/// time (`false`). Set to false if you plan to use direct screen taps or other
Expand Down
22 changes: 17 additions & 5 deletions Assets/GoogleVR/Scripts/GvrEditorEmulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Gvr.Internal;

/// Provides mouse-controlled head tracking emulation in the Unity editor.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrEditorEmulator")]
public class GvrEditorEmulator : MonoBehaviour {
// GvrEditorEmulator should only be compiled in the Editor.
//
Expand All @@ -30,7 +31,17 @@ public class GvrEditorEmulator : MonoBehaviour {
// queries the camera pose during Update or LateUpdate after GvrEditorEmulator has been
// updated will get the wrong value applied by GvrEditorEmulator intsead.
#if UNITY_EDITOR
public static GvrEditorEmulator Instance { get; private set; }
private static GvrEditorEmulator instance;
private static bool instance_searched_for = false;
public static GvrEditorEmulator Instance {
get {
if (instance == null && !instance_searched_for) {
instance = FindObjectOfType<GvrEditorEmulator>();
instance_searched_for = true;
}
return instance;
}
}
// Allocate an initial capacity; this will be resized if needed.
private static Camera[] AllCameras = new Camera[32];
private const string AXIS_MOUSE_X = "Mouse X";
Expand Down Expand Up @@ -89,13 +100,14 @@ public void UpdateEditorEmulation() {
}

void Awake() {
if (Instance != null) {
Debug.LogError("More than one GvrEditorEmulator instance was found in your scene. "
+ "Ensure that there is only one GvrEditorEmulator.");
if (Instance == null) {
instance = this;
} else if (Instance != this) {
Debug.LogError("More than one active GvrEditorEmulator instance was found in your scene. "
+ "Ensure that there is only one active GvrEditorEmulator.");
this.enabled = false;
return;
}
Instance = this;
}

void Update() {
Expand Down
10 changes: 7 additions & 3 deletions Assets/GoogleVR/Scripts/GvrSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,14 @@ public static IntPtr GetValidGvrNativePtrOrLogError() {
Debug.LogError("VR is disabled");
return IntPtr.Zero;
}
if (XRSettings.loadedDeviceName != VR_SDK_DAYDREAM
&& XRSettings.loadedDeviceName != VR_SDK_CARDBOARD) {
#if UNITY_2018_3_OR_NEWER
string loadedDeviceName = GvrXREventsSubscriber.loadedDeviceName;
#else // !UNITY_2018_3_OR_NEWER; this leaks 30 bytes of memory per update.
string loadedDeviceName = XRSettings.loadedDeviceName;
#endif // UNITY_2018_3_OR_NEWER
if (loadedDeviceName != VR_SDK_DAYDREAM && loadedDeviceName != VR_SDK_CARDBOARD) {
Debug.LogErrorFormat("Loaded VR SDK '{0}' must be '{1}' or '{2}'",
XRSettings.loadedDeviceName, VR_SDK_DAYDREAM, VR_SDK_CARDBOARD);
loadedDeviceName, VR_SDK_DAYDREAM, VR_SDK_CARDBOARD);
return IntPtr.Zero;
}
IntPtr gvrContextPtr = XRDevice.GetNativePtr();
Expand Down
2 changes: 1 addition & 1 deletion Assets/GoogleVR/Scripts/GvrUnitySdkVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/// Provides and logs versioning information for the GVR SDK for Unity.
/// </summary>
public class GvrUnitySdkVersion {
public const string GVR_SDK_VERSION = "1.150.0";
public const string GVR_SDK_VERSION = "1.170.0";

// Google VR SDK supports Unity 5.6 or newer.
#if !UNITY_5_6_OR_NEWER
Expand Down
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/Headset/GvrHeadset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/// such prefab in a scene.
///
/// This is a singleton object.
[HelpURL("https://developers.google.com/vr/unity/reference/class/GvrHeadset")]
public class GvrHeadset : MonoBehaviour {
private static GvrHeadset instance;

Expand Down
Binary file modified Assets/GoogleVR/Scripts/InstantPreview/InstantPreview.apk
Binary file not shown.
1 change: 1 addition & 0 deletions Assets/GoogleVR/Scripts/InstantPreview/InstantPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Threading;

namespace Gvr.Internal {
[HelpURL("https://developers.google.com/vr/unity/reference/class/InstantPreview")]
public class InstantPreview : MonoBehaviour {
private const string NoDevicesFoundAdbResult = "error: no devices/emulators found";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using UnityEngine;

[ExecuteInEditMode]
[HelpURL("https://developers.google.com/vr/unity/reference/class/InstantPreviewHelper")]
public class InstantPreviewHelper : MonoBehaviour {
public static string AdbPath;

Expand Down
Loading

0 comments on commit 5c97c6a

Please sign in to comment.