Added VR libraries
This commit is contained in:
8
Assets/GoogleVR/Editor/Controller.meta
Normal file
8
Assets/GoogleVR/Editor/Controller.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 796833fc7565bb949b56645546708700
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
141
Assets/GoogleVR/Editor/Controller/GvrControllerVisualEditor.cs
Normal file
141
Assets/GoogleVR/Editor/Controller/GvrControllerVisualEditor.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
// 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 permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
/// Custom editor for GvrControllerVisual.
|
||||
/// Enhances the visualization of the displayState and ensures that it can only be edited
|
||||
/// if the application isn't playing or if readControllerState is turned off.
|
||||
[CustomEditor(typeof(GvrControllerVisual)), CanEditMultipleObjects]
|
||||
public class GvrControllerVisualEditor : Editor {
|
||||
private SerializedProperty attachmentPrefabs;
|
||||
private SerializedProperty touchPadColor;
|
||||
private SerializedProperty appButtonColor;
|
||||
private SerializedProperty systemButtonColor;
|
||||
private SerializedProperty readControllerState;
|
||||
private SerializedProperty displayState;
|
||||
private SerializedProperty maximumAlpha;
|
||||
|
||||
private GUIStyle displayStateHeaderStyle;
|
||||
private GUIContent displayStateHeaderContent;
|
||||
private float displayStateHeaderHeight;
|
||||
|
||||
private const string DISPLAY_STATE_HEADER_TEXT = "DisplayState:";
|
||||
private const string DISPLAY_STATE_ITEM_PREFIX = "• ";
|
||||
private const int DISPLAY_STATE_HEADER_FONT_SIZE_OFFSET = 2;
|
||||
|
||||
private const string ATTACHMENT_PREFABS_PROP_NAME = "attachmentPrefabs";
|
||||
private const string TOUCH_PAD_COLOR_PROP_NAME = "touchPadColor";
|
||||
private const string APP_BUTTON_COLOR_PROP_NAME = "appButtonColor";
|
||||
private const string SYSTEM_BUTTON_COLOR_PROP_NAME = "systemButtonColor";
|
||||
private const string READ_CONTROLLER_STATE_PROP_NAME = "readControllerState";
|
||||
private const string DISPLAY_STATE_PROP_NAME = "displayState";
|
||||
private const string MAXIMUM_ALPHA_PROP_NAME = "maximumAlpha";
|
||||
|
||||
void OnEnable() {
|
||||
attachmentPrefabs = serializedObject.FindProperty(ATTACHMENT_PREFABS_PROP_NAME);
|
||||
touchPadColor = serializedObject.FindProperty(TOUCH_PAD_COLOR_PROP_NAME);
|
||||
appButtonColor = serializedObject.FindProperty(APP_BUTTON_COLOR_PROP_NAME);
|
||||
systemButtonColor = serializedObject.FindProperty(SYSTEM_BUTTON_COLOR_PROP_NAME);
|
||||
readControllerState = serializedObject.FindProperty(READ_CONTROLLER_STATE_PROP_NAME);
|
||||
displayState = serializedObject.FindProperty(DISPLAY_STATE_PROP_NAME);
|
||||
maximumAlpha = serializedObject.FindProperty(MAXIMUM_ALPHA_PROP_NAME);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
|
||||
// Add clickable script field, as would have been provided by DrawDefaultInspector()
|
||||
MonoScript script = MonoScript.FromMonoBehaviour (target as MonoBehaviour);
|
||||
EditorGUI.BeginDisabledGroup (true);
|
||||
EditorGUILayout.ObjectField ("Script", script, typeof(MonoScript), false);
|
||||
EditorGUI.EndDisabledGroup ();
|
||||
|
||||
CreateStylesAndContent();
|
||||
|
||||
// Show all properties except for display state.
|
||||
EditorGUILayout.PropertyField(attachmentPrefabs, true);
|
||||
EditorGUILayout.PropertyField(touchPadColor);
|
||||
EditorGUILayout.PropertyField(appButtonColor);
|
||||
EditorGUILayout.PropertyField(systemButtonColor);
|
||||
EditorGUILayout.PropertyField(readControllerState);
|
||||
|
||||
// Determine if the display state can currently be edited in the inspector.
|
||||
bool allowEditDisplayState = !readControllerState.boolValue || !Application.isPlaying;
|
||||
|
||||
if (!allowEditDisplayState) {
|
||||
// Prevents editing the display state in the inspector.
|
||||
GUI.enabled = false;
|
||||
}
|
||||
|
||||
Rect displayStateRect = EditorGUILayout.BeginVertical();
|
||||
GUI.Box(displayStateRect, "");
|
||||
|
||||
// Show the display state header.
|
||||
EditorGUILayout.LabelField(displayStateHeaderContent,
|
||||
displayStateHeaderStyle,
|
||||
GUILayout.Height(displayStateHeaderHeight));
|
||||
|
||||
// Indent the display state properties.
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
// Iterate through the child properties of the displayState property.
|
||||
SerializedProperty iter = displayState.Copy();
|
||||
SerializedProperty nextElement = displayState.Copy();
|
||||
bool hasNextElement = nextElement.Next(false);
|
||||
|
||||
iter.NextVisible(true);
|
||||
do {
|
||||
// It iter is the same as nextElement, then the iter has moved beyond the children of the
|
||||
// display state which means it has finished showing the display state.
|
||||
if (hasNextElement && SerializedProperty.EqualContents(nextElement, iter)) {
|
||||
break;
|
||||
}
|
||||
|
||||
GUIContent content = new GUIContent(DISPLAY_STATE_ITEM_PREFIX + iter.displayName);
|
||||
EditorGUILayout.PropertyField(iter, content);
|
||||
} while (iter.NextVisible(false));
|
||||
|
||||
// End the vertical region and draw the box.
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
// Reset GUI.enabled.
|
||||
if (!allowEditDisplayState) {
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(maximumAlpha);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void CreateStylesAndContent() {
|
||||
if (displayStateHeaderContent == null) {
|
||||
displayStateHeaderContent = new GUIContent(DISPLAY_STATE_HEADER_TEXT);
|
||||
}
|
||||
|
||||
if (displayStateHeaderStyle == null) {
|
||||
displayStateHeaderStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
|
||||
displayStateHeaderStyle.fontSize =
|
||||
displayStateHeaderStyle.font.fontSize + DISPLAY_STATE_HEADER_FONT_SIZE_OFFSET;
|
||||
|
||||
displayStateHeaderHeight = displayStateHeaderStyle.CalcSize(displayStateHeaderContent).y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05d7d64713447433b86cb9a4e3d48560
|
||||
timeCreated: 1498249337
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
143
Assets/GoogleVR/Editor/Controller/GvrLaserPointerEditor.cs
Normal file
143
Assets/GoogleVR/Editor/Controller/GvrLaserPointerEditor.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
// 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 permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
/// Custom editor for GvrLaserPointer.
|
||||
/// Adds buttons that allows user's to set the recommended default values for the different
|
||||
/// raycast modes.
|
||||
[CustomEditor(typeof(GvrLaserPointer)), CanEditMultipleObjects]
|
||||
public class GvrLaserPointerEditor : Editor {
|
||||
private SerializedProperty mode;
|
||||
private SerializedProperty overridePointerCamera;
|
||||
private SerializedProperty maxPointerDistance;
|
||||
private SerializedProperty defaultReticleDistance;
|
||||
private SerializedProperty rayIntersection;
|
||||
private SerializedProperty drawDebugRays;
|
||||
|
||||
|
||||
public const string RAYCAST_MODE_PROP_NAME = "raycastMode";
|
||||
public const string OVERRIDE_POINTER_CAMERA_PROP_NAME = "overridePointerCamera";
|
||||
public const string MAX_POINTER_DISTANCE_PROP_NAME = "maxPointerDistance";
|
||||
public const string DEFAULT_RETICLE_DISTANCE_PROP_NAME = "defaultReticleDistance";
|
||||
public const string RAY_INTERSECTION_PROP_NAME = "overrideCameraRayIntersectionDistance";
|
||||
public const string DRAW_DEBUG_RAYS_PROP_NAME = "drawDebugRays";
|
||||
|
||||
void OnEnable() {
|
||||
mode = serializedObject.FindProperty(RAYCAST_MODE_PROP_NAME);
|
||||
overridePointerCamera = serializedObject.FindProperty(OVERRIDE_POINTER_CAMERA_PROP_NAME);
|
||||
maxPointerDistance = serializedObject.FindProperty(MAX_POINTER_DISTANCE_PROP_NAME);
|
||||
defaultReticleDistance = serializedObject.FindProperty(DEFAULT_RETICLE_DISTANCE_PROP_NAME);
|
||||
rayIntersection = serializedObject.FindProperty(RAY_INTERSECTION_PROP_NAME);
|
||||
drawDebugRays = serializedObject.FindProperty(DRAW_DEBUG_RAYS_PROP_NAME);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
|
||||
// Add clickable script field, as would have been provided by DrawDefaultInspector()
|
||||
MonoScript script = MonoScript.FromMonoBehaviour(target as MonoBehaviour);
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
Rect defaultsRect = EditorGUILayout.BeginVertical();
|
||||
GUI.Box(defaultsRect, /* No label. */ "");
|
||||
|
||||
GUILayout.Space(3.0f);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button("Hybrid")) {
|
||||
SetDefaultsForRaycastMode(GvrBasePointer.RaycastMode.Hybrid);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Camera")) {
|
||||
SetDefaultsForRaycastMode(GvrBasePointer.RaycastMode.Camera);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Direct")) {
|
||||
SetDefaultsForRaycastMode(GvrBasePointer.RaycastMode.Direct);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.HelpBox("Use the above Raycast Mode buttons to reset the following properties to their recommended values.\n\n" +
|
||||
"GvrLaserPointer:\n" +
|
||||
" • " + mode.displayName + "\n" +
|
||||
" • " + rayIntersection.displayName + "\n\n" +
|
||||
"GvrLaserVisual:\n" +
|
||||
" • Max Laser Distance\n" +
|
||||
" • Shrink Laser\n", MessageType.Info);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(maxPointerDistance);
|
||||
EditorGUILayout.PropertyField(defaultReticleDistance);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Advanced:", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(mode);
|
||||
EditorGUILayout.PropertyField(overridePointerCamera);
|
||||
EditorGUILayout.PropertyField(rayIntersection);
|
||||
EditorGUILayout.PropertyField(drawDebugRays);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void SetDefaultsForRaycastMode(GvrBasePointer.RaycastMode raycastMode) {
|
||||
switch (raycastMode) {
|
||||
case GvrBasePointer.RaycastMode.Hybrid:
|
||||
mode.intValue = (int)raycastMode;
|
||||
rayIntersection.floatValue = GvrVRHelpers.GetRayIntersection(raycastMode);
|
||||
SetPropertiesForVisual(GvrVRHelpers.GetShrinkLaser(raycastMode), GvrVRHelpers.GetRecommendedMaxLaserDistance(raycastMode));
|
||||
break;
|
||||
case GvrBasePointer.RaycastMode.Camera:
|
||||
mode.intValue = (int)raycastMode;
|
||||
rayIntersection.floatValue = GvrVRHelpers.GetRayIntersection(raycastMode);
|
||||
SetPropertiesForVisual(GvrVRHelpers.GetShrinkLaser(raycastMode), GvrVRHelpers.GetRecommendedMaxLaserDistance(raycastMode));
|
||||
break;
|
||||
case GvrBasePointer.RaycastMode.Direct:
|
||||
mode.intValue = (int)raycastMode;
|
||||
rayIntersection.floatValue = GvrVRHelpers.GetRayIntersection(raycastMode);
|
||||
SetPropertiesForVisual(GvrVRHelpers.GetShrinkLaser(raycastMode), GvrVRHelpers.GetRecommendedMaxLaserDistance(raycastMode));
|
||||
break;
|
||||
default:
|
||||
Debug.LogError("Trying to set defaults for invalid Raycast Mode: " + raycastMode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPropertiesForVisual(bool shrinkLaser, float maxLaserDistance) {
|
||||
foreach (Object obj in serializedObject.targetObjects) {
|
||||
GvrLaserVisual laserVisual = (obj as MonoBehaviour).GetComponent<GvrLaserVisual>();
|
||||
if (laserVisual != null) {
|
||||
SerializedObject serializedLaserVisual = new SerializedObject(laserVisual);
|
||||
|
||||
SerializedProperty serializedShrinkLaser =
|
||||
serializedLaserVisual.FindProperty(GvrLaserVisualEditor.SHRINK_LASER_PROP_NAME);
|
||||
serializedShrinkLaser.boolValue = shrinkLaser;
|
||||
|
||||
SerializedProperty serializedMaxLaserDistance =
|
||||
serializedLaserVisual.FindProperty(GvrLaserVisualEditor.MAX_LASER_DISTANCE_PROP_NAME);
|
||||
serializedMaxLaserDistance.floatValue = maxLaserDistance;
|
||||
|
||||
serializedLaserVisual.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc6e38fe705a640ba9cc80555465b13e
|
||||
timeCreated: 1498249337
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
114
Assets/GoogleVR/Editor/Controller/GvrLaserVisualEditor.cs
Normal file
114
Assets/GoogleVR/Editor/Controller/GvrLaserVisualEditor.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
// 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 permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
/// Custom editor for GvrLaserVisual.
|
||||
/// Shows the relationship between the shrinkLaser property and other related properties.
|
||||
[CustomEditor(typeof(GvrLaserVisual)), CanEditMultipleObjects]
|
||||
public class GvrLaserVisualEditor : Editor {
|
||||
private SerializedProperty laserColor;
|
||||
private SerializedProperty laserColorEnd;
|
||||
private SerializedProperty maxLaserDistance;
|
||||
private SerializedProperty shrinkLaser;
|
||||
private SerializedProperty shrunkScale;
|
||||
private SerializedProperty beginShrinkAngleDegrees;
|
||||
private SerializedProperty endShrinkAngleDegrees;
|
||||
private SerializedProperty lerpSpeed;
|
||||
private SerializedProperty lerpThreshold;
|
||||
private SerializedProperty reticle;
|
||||
private SerializedProperty controller;
|
||||
|
||||
public const string LASER_COLOR_PROP_NAME = "laserColor";
|
||||
public const string LASER_COLOR_END_PROP_NAME = "laserColorEnd";
|
||||
public const string MAX_LASER_DISTANCE_PROP_NAME = "maxLaserDistance";
|
||||
public const string SHRINK_LASER_PROP_NAME = "shrinkLaser";
|
||||
public const string SHURNK_SCALE_PROP_NAME = "shrunkScale";
|
||||
public const string BEGIN_SHRINKING_ANGLE_DEGREES_PROP_NAME = "beginShrinkAngleDegrees";
|
||||
public const string END_SHRINKING_ANGLE_DEGREES_PROP_NAME = "endShrinkAngleDegrees";
|
||||
public const string LERP_SPEED_PROP_NAME = "lerpSpeed";
|
||||
public const string LERP_THRESHOLD_PROP_NAME = "lerpThreshold";
|
||||
public const string RETICLE_PROP_NAME = "reticle";
|
||||
public const string CONTROLLER_PROP_NAME = "controller";
|
||||
|
||||
private const string ITEM_PREFIX = "• ";
|
||||
|
||||
void OnEnable() {
|
||||
laserColor = serializedObject.FindProperty(LASER_COLOR_PROP_NAME);
|
||||
laserColorEnd = serializedObject.FindProperty(LASER_COLOR_END_PROP_NAME);
|
||||
maxLaserDistance = serializedObject.FindProperty(MAX_LASER_DISTANCE_PROP_NAME);
|
||||
shrinkLaser = serializedObject.FindProperty(SHRINK_LASER_PROP_NAME);
|
||||
shrunkScale = serializedObject.FindProperty(SHURNK_SCALE_PROP_NAME);
|
||||
beginShrinkAngleDegrees = serializedObject.FindProperty(BEGIN_SHRINKING_ANGLE_DEGREES_PROP_NAME);
|
||||
endShrinkAngleDegrees = serializedObject.FindProperty(END_SHRINKING_ANGLE_DEGREES_PROP_NAME);
|
||||
lerpSpeed = serializedObject.FindProperty(LERP_SPEED_PROP_NAME);
|
||||
lerpThreshold = serializedObject.FindProperty(LERP_THRESHOLD_PROP_NAME);
|
||||
reticle = serializedObject.FindProperty(RETICLE_PROP_NAME);
|
||||
controller = serializedObject.FindProperty(CONTROLLER_PROP_NAME);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
|
||||
// Add clickable script field, as would have been provided by DrawDefaultInspector()
|
||||
MonoScript script = MonoScript.FromMonoBehaviour(target as MonoBehaviour);
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
// Show properties for the laser visual.
|
||||
EditorGUILayout.PropertyField(reticle);
|
||||
EditorGUILayout.PropertyField(controller);
|
||||
EditorGUILayout.PropertyField(laserColor);
|
||||
EditorGUILayout.PropertyField(laserColorEnd);
|
||||
EditorGUILayout.PropertyField(maxLaserDistance);
|
||||
EditorGUILayout.PropertyField(lerpSpeed);
|
||||
EditorGUILayout.PropertyField(lerpThreshold);
|
||||
EditorGUILayout.PropertyField(shrinkLaser);
|
||||
|
||||
// Show properties for shrinking animation. Only enabled if shrinkLaser is enabled.
|
||||
if (!shrinkLaser.boolValue) {
|
||||
GUI.enabled = false;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
Rect shrinkLaserRect = EditorGUILayout.BeginVertical();
|
||||
shrinkLaserRect = EditorGUI.IndentedRect(shrinkLaserRect);
|
||||
GUI.Box(shrinkLaserRect, "");
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(shrunkScale,
|
||||
new GUIContent(ITEM_PREFIX + shrunkScale.displayName));
|
||||
|
||||
EditorGUILayout.PropertyField(beginShrinkAngleDegrees,
|
||||
new GUIContent(ITEM_PREFIX + beginShrinkAngleDegrees.displayName));
|
||||
|
||||
EditorGUILayout.PropertyField(endShrinkAngleDegrees,
|
||||
new GUIContent(ITEM_PREFIX + endShrinkAngleDegrees.displayName));
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
if (!shrinkLaser.boolValue) {
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66fe40e11a2514648906e6825b026b85
|
||||
timeCreated: 1498249337
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/GoogleVR/Editor/Controller/GvrTooltipEditor.cs
Normal file
29
Assets/GoogleVR/Editor/Controller/GvrTooltipEditor.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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 permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
/// A custom editor for the GvrTooltip script. It exists to surface to the user that the tooltip
|
||||
/// changes based on handedness, and to make it easy to preview the handedness settings.
|
||||
[CustomEditor(typeof(GvrTooltip)), CanEditMultipleObjects]
|
||||
public class GvrTooltipEditor : Editor {
|
||||
public override void OnInspectorGUI() {
|
||||
DrawDefaultInspector();
|
||||
EditorGUILayout.LabelField("Current Handedness", GvrSettings.Handedness.ToString(), EditorStyles.boldLabel);
|
||||
if (GUILayout.Button("Change Handedness")) {
|
||||
EditorWindow.GetWindow(typeof(GvrEditorSettings));
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/GoogleVR/Editor/Controller/GvrTooltipEditor.cs.meta
Normal file
12
Assets/GoogleVR/Editor/Controller/GvrTooltipEditor.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23485e28fa60c463f8235998a0e76e6a
|
||||
timeCreated: 1482187746
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/GoogleVR/Editor/EventSystem.meta
Normal file
8
Assets/GoogleVR/Editor/EventSystem.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44f73449456ed5d44b7203f5dfba14d6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,77 @@
|
||||
// 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 permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(GvrPointerScrollInput), true)]
|
||||
public class GvrPointerScrollInputEditor : PropertyDrawer {
|
||||
private bool isExpanded = true;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
int rows = GetNumRows(property);
|
||||
float totalHeight = position.height;
|
||||
float rowHeight = totalHeight / rows;
|
||||
position.height = rowHeight;
|
||||
|
||||
isExpanded = EditorGUI.Foldout(position, isExpanded, label);
|
||||
|
||||
if (isExpanded) {
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
// Inertia property.
|
||||
SerializedProperty inertia =
|
||||
property.FindPropertyRelative(GvrPointerScrollInput.PROPERTY_NAME_INERTIA);
|
||||
|
||||
position.y += rowHeight;
|
||||
EditorGUI.PropertyField(position, inertia);
|
||||
|
||||
if (inertia.boolValue) {
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
// Deceleration rate property.
|
||||
SerializedProperty decelerationRate =
|
||||
property.FindPropertyRelative(GvrPointerScrollInput.PROPERTY_NAME_DECELERATION_RATE);
|
||||
|
||||
position.y += rowHeight;
|
||||
EditorGUI.PropertyField(position, decelerationRate);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
|
||||
return base.GetPropertyHeight(property, label) * GetNumRows(property);
|
||||
}
|
||||
|
||||
private int GetNumRows(SerializedProperty property) {
|
||||
SerializedProperty inertia =
|
||||
property.FindPropertyRelative(GvrPointerScrollInput.PROPERTY_NAME_INERTIA);
|
||||
|
||||
if (!isExpanded) {
|
||||
return 1;
|
||||
} else if (!inertia.boolValue) {
|
||||
return 2;
|
||||
} else {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da538b2d940864934bfd4a6f2e6d0602
|
||||
timeCreated: 1487103089
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
130
Assets/GoogleVR/Editor/GvrBuildProcessor.cs
Normal file
130
Assets/GoogleVR/Editor/GvrBuildProcessor.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
// 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 permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Only invoke custom build processor when building for Android or iOS.
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using System.Linq;
|
||||
|
||||
#if UNITY_IOS
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using System.IO;
|
||||
#endif
|
||||
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
using UnityEngine.XR;
|
||||
#else
|
||||
using XRSettings = UnityEngine.VR.VRSettings;
|
||||
#endif // UNITY_2017_2_OR_NEWER
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
using UnityEditor.Build.Reporting;
|
||||
#endif
|
||||
|
||||
// Notifies users if they build for Android or iOS without Cardboard or Daydream enabled.
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
class GvrBuildProcessor : IPreprocessBuildWithReport, IPostprocessBuildWithReport {
|
||||
#else
|
||||
class GvrBuildProcessor : IPreprocessBuild, IPostprocessBuild {
|
||||
#endif
|
||||
private const string VR_SETTINGS_NOT_ENABLED_ERROR_MESSAGE_FORMAT =
|
||||
"To use the Google VR SDK on {0}, 'Player Settings > Virtual Reality Supported' setting must be checked.\n" +
|
||||
"Please fix this setting and rebuild your app.";
|
||||
private const string IOS_MISSING_GVR_SDK_ERROR_MESSAGE =
|
||||
"To use the Google VR SDK on iOS, 'Player Settings > Virtual Reality SDKs' must include 'Cardboard'.\n" +
|
||||
"Please fix this setting and rebuild your app.";
|
||||
private const string ANDROID_MISSING_GVR_SDK_ERROR_MESSAGE =
|
||||
"To use the Google VR SDK on Android, 'Player Settings > Virtual Reality SDKs' must include 'Daydream' or 'Cardboard'.\n" +
|
||||
"Please fix this setting and rebuild your app.";
|
||||
|
||||
public int callbackOrder {
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
OnPreprocessBuild(report.summary.platform, report.summary.outputPath);
|
||||
}
|
||||
#endif
|
||||
|
||||
public void OnPreprocessBuild (BuildTarget target, string path)
|
||||
{
|
||||
if (target != BuildTarget.Android && target != BuildTarget.iOS) {
|
||||
// Do nothing when not building for Android or iOS.
|
||||
return;
|
||||
}
|
||||
|
||||
// 'Player Settings > Virtual Reality Supported' must be enabled.
|
||||
if (!IsVRSupportEnabled()) {
|
||||
Debug.LogErrorFormat(VR_SETTINGS_NOT_ENABLED_ERROR_MESSAGE_FORMAT, target);
|
||||
}
|
||||
|
||||
if (target == BuildTarget.Android) {
|
||||
// When building for Android at least one VR SDK must be included.
|
||||
// For Google VR valid VR SDKs are 'Daydream' and/or 'Cardboard'.
|
||||
if (!IsSDKOtherThanNoneIncluded()) {
|
||||
Debug.LogError(ANDROID_MISSING_GVR_SDK_ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
if (target == BuildTarget.iOS) {
|
||||
// When building for iOS at least one VR SDK must be included.
|
||||
// For Google VR only 'Cardboard' is supported.
|
||||
if (!IsSDKOtherThanNoneIncluded()) {
|
||||
Debug.LogError(IOS_MISSING_GVR_SDK_ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
public void OnPostprocessBuild(BuildReport report) {
|
||||
OnPostprocessBuild(report.summary.platform, report.summary.outputPath);
|
||||
}
|
||||
#endif
|
||||
|
||||
public void OnPostprocessBuild(BuildTarget target, string outputPath) {
|
||||
#if UNITY_IOS
|
||||
// Add Camera usage description for scanning viewer QR codes on iOS.
|
||||
if (target == BuildTarget.iOS) {
|
||||
// Read plist
|
||||
var plistPath = Path.Combine(outputPath, "Info.plist");
|
||||
var plist = new PlistDocument();
|
||||
plist.ReadFromFile(plistPath);
|
||||
|
||||
// Update value
|
||||
PlistElementDict rootDict = plist.root;
|
||||
rootDict.SetString("NSCameraUsageDescription", "Scan Cardboard viewer QR code");
|
||||
|
||||
// Write plist
|
||||
File.WriteAllText(plistPath, plist.WriteToString());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 'Player Settings > Virtual Reality Supported' enabled?
|
||||
private bool IsVRSupportEnabled() {
|
||||
return PlayerSettings.virtualRealitySupported;
|
||||
}
|
||||
|
||||
// 'Player Settings > Virtual Reality SDKs' includes any VR SDK other than 'None'?
|
||||
private bool IsSDKOtherThanNoneIncluded() {
|
||||
bool containsNone = XRSettings.supportedDevices.Contains(GvrSettings.VR_SDK_NONE);
|
||||
int numSdks = XRSettings.supportedDevices.Length;
|
||||
return containsNone ? numSdks > 1 : numSdks > 0;
|
||||
}
|
||||
}
|
||||
#endif // UNITY_ANDROID || UNITY_IOS
|
||||
12
Assets/GoogleVR/Editor/GvrBuildProcessor.cs.meta
Normal file
12
Assets/GoogleVR/Editor/GvrBuildProcessor.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acad0e6b1721a4b30992f78c06434321
|
||||
timeCreated: 1490158482
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/GoogleVR/Editor/GvrEditorEmulatorEditor.cs
Normal file
40
Assets/GoogleVR/Editor/GvrEditorEmulatorEditor.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
// 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 permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
/// A custom editor for the GvrEditorEmulator script.
|
||||
/// It adds an info panel describing the camera controls.
|
||||
[CustomEditor(typeof(GvrEditorEmulator)), CanEditMultipleObjects]
|
||||
public class GvrEditorEmulatorEditor : Editor {
|
||||
private float infoHeight;
|
||||
|
||||
private const string INFO_TEXT = "Camera Controls:\n" +
|
||||
" • Alt + Move Mouse = Change Yaw/Pitch\n" +
|
||||
" • Ctrl + Move Mouse = Change Roll";
|
||||
|
||||
private const int NUM_INFO_LINES = 3;
|
||||
|
||||
void OnEnable() {
|
||||
infoHeight = GvrInfoDrawer.GetHeightForLines(NUM_INFO_LINES);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
DrawDefaultInspector();
|
||||
|
||||
Rect rect = EditorGUILayout.GetControlRect(false, infoHeight);
|
||||
GvrInfoDrawer.Draw(rect, INFO_TEXT);
|
||||
}
|
||||
}
|
||||
12
Assets/GoogleVR/Editor/GvrEditorEmulatorEditor.cs.meta
Normal file
12
Assets/GoogleVR/Editor/GvrEditorEmulatorEditor.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f789f1d07e73f42b398b211da58efc42
|
||||
timeCreated: 1498601428
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Assets/GoogleVR/Editor/GvrEditorMenu.cs
Normal file
49
Assets/GoogleVR/Editor/GvrEditorMenu.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2015 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 UnityEditor;
|
||||
|
||||
public class GvrEditorMenu {
|
||||
[MenuItem("GoogleVR/Documentation/Developers Site", false, 100)]
|
||||
private static void OpenDocumentation() {
|
||||
Application.OpenURL("https://developers.google.com/vr");
|
||||
}
|
||||
|
||||
[MenuItem("GoogleVR/Documentation/Unity Guide", false, 100)]
|
||||
private static void OpenUnityGuide() {
|
||||
Application.OpenURL("https://developers.google.com/vr/unity/guide");
|
||||
}
|
||||
|
||||
[MenuItem("GoogleVR/Documentation/Release Notes", false, 100)]
|
||||
private static void OpenReleaseNotes() {
|
||||
Application.OpenURL("https://developers.google.com/vr/unity/release-notes");
|
||||
}
|
||||
|
||||
[MenuItem("GoogleVR/Documentation/Known Issues", false, 100)]
|
||||
private static void OpenKnownIssues() {
|
||||
Application.OpenURL("https://developers.google.com/vr/unity/release-notes#known_issues");
|
||||
}
|
||||
|
||||
[MenuItem("GoogleVR/Editor Settings", false, 100)]
|
||||
private static void OpenEditorSettings() {
|
||||
EditorWindow.GetWindow(typeof(GvrEditorSettings));
|
||||
}
|
||||
|
||||
[MenuItem("GoogleVR/Report Bug", false, 100)]
|
||||
private static void OpenReportBug() {
|
||||
Application.OpenURL("https://github.com/googlesamples/cardboard-unity/issues");
|
||||
}
|
||||
|
||||
}
|
||||
12
Assets/GoogleVR/Editor/GvrEditorMenu.cs.meta
Normal file
12
Assets/GoogleVR/Editor/GvrEditorMenu.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5eb60798954e54a7280c0cd353773edf
|
||||
timeCreated: 1448497144
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/GoogleVR/Editor/GvrEditorSettings.cs
Normal file
34
Assets/GoogleVR/Editor/GvrEditorSettings.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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 permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
/// A custom editor window used to set editor preferences for GoogleVR.
|
||||
/// Editor preferences are editor specific options that help build and test
|
||||
/// applications from within the Unity Editor.
|
||||
class GvrEditorSettings : EditorWindow {
|
||||
void OnGUI () {
|
||||
// Label for Controller Emulator settings
|
||||
EditorGUILayout.LabelField("Controller Emulator", EditorStyles.boldLabel);
|
||||
|
||||
// Option to control Handedness
|
||||
GvrSettings.UserPrefsHandedness oldHandedness = GvrSettings.Handedness;
|
||||
GvrSettings.Handedness = (GvrSettings.UserPrefsHandedness) EditorGUILayout.EnumPopup("Handedness", oldHandedness);
|
||||
if (oldHandedness != GvrSettings.Handedness) {
|
||||
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/GoogleVR/Editor/GvrEditorSettings.cs.meta
Normal file
12
Assets/GoogleVR/Editor/GvrEditorSettings.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce0ec89649a704bd991b4db7e412794f
|
||||
timeCreated: 1482180802
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user