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.100.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rusmaxham committed Oct 7, 2017
1 parent ca1e250 commit a37f02e
Show file tree
Hide file tree
Showing 27 changed files with 85 additions and 17 deletions.
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 not shown.
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/iOS/libaudioplugingvrunity.a
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/x86/audioplugingvrunity.dll
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/x86/instant_preview_shared.dll
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/x86/instant_preview_unity_plugin.dll
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/x86_64/audioplugingvrunity.bundle
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/x86_64/audioplugingvrunity.dll
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/x86_64/instant_preview_shared.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/x86_64/instant_preview_unity_plugin.dll
Binary file not shown.
Binary file modified Assets/GoogleVR/Plugins/x86_64/libaudioplugingvrunity.so
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ namespace Gvr.Internal {
/// The right mouse button is used for the appButton.
/// The middle mouse button is used for the homeButton.
class MouseControllerProvider : IControllerProvider {
private const string AXIS_MOUSE_X = "Mouse X";
private const string AXIS_MOUSE_Y = "Mouse Y";

private ControllerState state = new ControllerState();

private Vector3 lastMousePosition;
private Vector2 mouseDelta = new Vector2();

/// Need to store the state of the buttons from the previous frame.
/// This is because Input.GetMouseButtonDown and Input.GetMouseButtonUp
Expand All @@ -35,8 +38,8 @@ class MouseControllerProvider : IControllerProvider {
private bool wasHomeButton;
private bool wasTouching;

private const float ROTATE_SENSITIVITY = 0.075f;
private const float TOUCH_SENSITIVITY = 0.002f;
private const float ROTATE_SENSITIVITY = 4.5f;
private const float TOUCH_SENSITIVITY = .12f;
private static readonly Vector3 INVERT_Y = new Vector3(1, -1, 1);

public static bool IsMouseAvailable {
Expand Down Expand Up @@ -95,9 +98,10 @@ public void OnPause() {}
public void OnResume() {}

private void UpdateState() {
GvrCursorHelper.ControllerEmulationActive = IsMouseAvailable;

if (!IsMouseAvailable) {
ClearState();
lastMousePosition = Input.mousePosition;
return;
}

Expand All @@ -108,19 +112,20 @@ private void UpdateState() {

UpdateButtonStates();

mouseDelta.Set(
Input.GetAxis(AXIS_MOUSE_X),
Input.GetAxis(AXIS_MOUSE_Y)
);

if (state.isTouching) {
UpdateTouchPos();
} else {
UpdateOrientation();
}

lastMousePosition = Input.mousePosition;
}

private void UpdateTouchPos() {
Vector3 currentMousePosition = Input.mousePosition;
Vector3 mouseDelta = currentMousePosition - lastMousePosition;

Vector2 touchDelta = mouseDelta * TOUCH_SENSITIVITY;
touchDelta.y *= -1.0f;

Expand All @@ -130,7 +135,6 @@ private void UpdateTouchPos() {
}

private void UpdateOrientation() {
Vector3 mouseDelta = Input.mousePosition - lastMousePosition;
Vector3 deltaDegrees = Vector3.Scale(mouseDelta, INVERT_Y) * ROTATE_SENSITIVITY;

state.gyro = deltaDegrees * (Mathf.Deg2Rad / Time.deltaTime);
Expand Down
4 changes: 4 additions & 0 deletions Assets/GoogleVR/Scripts/GvrEditorEmulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void Update() {

bool rolled = false;
if (CanChangeYawPitch()) {
GvrCursorHelper.HeadEmulationActive = true;
mouseX += Input.GetAxis(AXIS_MOUSE_X) * 5;
if (mouseX <= -180) {
mouseX += 360;
Expand All @@ -76,9 +77,12 @@ void Update() {
mouseY -= Input.GetAxis(AXIS_MOUSE_Y) * 2.4f;
mouseY = Mathf.Clamp(mouseY, -85, 85);
} else if (CanChangeRoll()) {
GvrCursorHelper.HeadEmulationActive = true;
rolled = true;
mouseZ += Input.GetAxis(AXIS_MOUSE_X) * 5;
mouseZ = Mathf.Clamp(mouseZ, -85, 85);
} else {
GvrCursorHelper.HeadEmulationActive = false;
}

if (!rolled) {
Expand Down
4 changes: 2 additions & 2 deletions Assets/GoogleVR/Scripts/GvrUnitySdkVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using UnityEngine;

/// <summary>
/// Provides and logs versioning information for the GVR Unity SDK.
/// Provides and logs versioning information for the GVR SDK for Unity.
/// </summary>
public class GvrUnitySdkVersion {
public const string GVR_SDK_VERSION = "1.100.0";
Expand All @@ -27,7 +27,7 @@ public class GvrUnitySdkVersion {

// Only log GVR SDK version when running on an Android or iOS device.
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
private const string VERSION_HEADER = "GVR Unity SDK Version: ";
private const string VERSION_HEADER = "GVR SDK for Unity version: ";

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void LogGvrUnitySdkVersion() {
Expand Down
Binary file modified Assets/GoogleVR/Scripts/InstantPreview/InstantPreview.apk
Binary file not shown.
48 changes: 48 additions & 0 deletions Assets/GoogleVR/Scripts/Utilities/GvrCursorHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2017 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 permissioßns and
// limitations under the License.

using System;
using UnityEngine;

namespace Gvr.Internal {
/// Manages cursor lock state while developer is using editor head and controller emulation.
public class GvrCursorHelper {

// Whether MouseControllerProvider is currently tracking mouse movement.
private static bool cachedHeadEmulationActive;

// Whether GvrEditorEmulator is currently tracking mouse movement.
private static bool cachedControllerEmulationActive;

public static bool HeadEmulationActive {
set {
cachedHeadEmulationActive = value;
UpdateCursorLockState();
}
}

public static bool ControllerEmulationActive {
set {
cachedControllerEmulationActive = value;
UpdateCursorLockState();
}
}

private static void UpdateCursorLockState() {
bool active = cachedHeadEmulationActive || cachedControllerEmulationActive;
Cursor.lockState = active ? CursorLockMode.Locked : CursorLockMode.None;
}

}
}
12 changes: 12 additions & 0 deletions Assets/GoogleVR/Scripts/Utilities/GvrCursorHelper.cs.meta

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

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ For first time users, see the Get Started Guides for [Android Cardboard](https:/

Please note, we do not accept pull requests.

## Migration to Unity 5.6 from GVR Unity SDK 1.40 or lower
__Unity versions 5.6 or newer are required as of v1.40 of the GVR Unity SDK.__
## Migration to Unity 5.6 from GVR SDK for Unity 1.40 or lower
__Unity versions 5.6 or newer are required as of v1.40 of the GVR SDK for Unity.__

Migration steps:

1. Update the GVR Unity SDK to [1.40](https://github.com/googlevr/gvr-unity-sdk/blob/a3d1033260dab57cb0f4a62a770796fbd09fe37a/GoogleVRForUnity.unitypackage).
1. Update the GVR SDK for Unity to [1.40](https://github.com/googlevr/gvr-unity-sdk/blob/a3d1033260dab57cb0f4a62a770796fbd09fe37a/GoogleVRForUnity.unitypackage).
2. Migrate to Unity 5.6.0f3, or any newer version. The SDK will import or remove the unnecessary GVR libraries.
3. Update the GVR Unity SDK to 1.70 (or latest).
3. Update the GVR SDK for Unity to 1.70 (or latest).

## Usage Guide
As of the 1.70 release, the `gvr-unity-sdk` git repo can be cloned and used directly in a Unity project.
Expand All @@ -27,8 +27,8 @@ As of the 1.70 release, the `gvr-unity-sdk` git repo can be cloned and used dire
* __Samples__: [Daydream Elements](https://github.com/googlevr/daydream-elements)
* __Workflow__: [Instant Preview](https://github.com/googlevr/gvr-instant-preview)

## Pod update to the latest GVR iOS SDK
As of Unity 5.6, the generated Cocoapod can be updated to the latest GVR iOS SDK by following these steps.
## Pod update to the latest GVR SDK for iOS
As of Unity 5.6, the generated Cocoapod can be updated to the latest GVR SDK for iOS by following these steps.

* Build an XCode project from Unity.
* In a terminal, change directories into the XCode project folder.
Expand Down

0 comments on commit a37f02e

Please sign in to comment.