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

Commit

Permalink
Version 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
smdol committed May 28, 2015
1 parent 3a9f4cb commit dc29f68
Show file tree
Hide file tree
Showing 29 changed files with 3,770 additions and 967 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,16 @@ v0.4.10 (4/16/2015):
- Fixed CardboardGUI's Head property in the Legacy demo scene.
- Fixed the neck model Z offset in the Editor.
- Fixed a bug in CardboardEditor which failed to save the Editor-only settings.

v0.5 (5/28/2015):
- The iOS build platform is now supported.
- Added a new C++ native code implementation for head tracking and distortion correction.
- The Java-based native code implementation has been moved to the Legacy folder.
- Refactored Cardboard.cs into a front-end Unity API and a back-end VRDevice class.
- VRDevice implementations provided for Android, iOS, and Unity editor.
- Some Cardboard properties have been renamed (but the old names still work).
- Added a Tilt event for when the viewer is turned on its side.
- Added C# events to Cardboard for responding to Trigger and Tilt events.
- Added more phone and viewer profiles to the in-editor simulation menus.
- If native code distortion correction is not supported, fall back to using an Image Effect.
- If native code UI layer is not supported, fall back to rendering it in Unity.
21 changes: 16 additions & 5 deletions Cardboard/DemoScene/DemoScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ Prefab:
propertyPath: neckModelScale
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2}
propertyPath: UseUnityRemoteInput
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2}
propertyPath: deviceType
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2}
m_RootGameObject: {fileID: 1427108206}
Expand Down Expand Up @@ -893,7 +901,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1427108208}
- m_Target: {fileID: 955127921}
m_MethodName: ToggleVRMode
m_Mode: 1
m_Arguments:
Expand Down Expand Up @@ -2281,6 +2289,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f1578549c7fcc4f6fa1b063992091672, type: 3}
m_Name:
m_EditorClassIdentifier:
trackRotation: 1
trackPosition: 1
target: {fileID: 0}
updateEarly: 0
--- !u!1 &1427108206
Expand Down Expand Up @@ -2324,18 +2334,19 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a40b544b8c3553c40852ae7ad35a9343, type: 3}
m_Name:
m_EditorClassIdentifier:
nativeDistortionCorrection: 1
distortionCorrection: 1
vrModeEnabled: 1
enableAlignmentMarker: 1
enableSettingsButton: 1
tapIsTrigger: 1
TapIsTrigger: 1
neckModelScale: 1
backButtonExitsApp: 1
autoDriftCorrection: 1
syncWithCardboardApp: 0
autoUntiltHead: 1
simulateDistortionCorrection: 1
UseUnityRemoteInput: 0
screenSize: 0
deviceType: 0
simulateDistortionCorrection: 1
--- !u!1 &1499060387
GameObject:
m_ObjectHideFlags: 0
Expand Down
2 changes: 1 addition & 1 deletion Cardboard/DemoScene/GroundPlane.mat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Material:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: GroundPlane
m_Shader: {fileID: 10703, guid: 0000000000000000f000000000000000, type: 0}
m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: []
m_CustomRenderQueue: -1
m_SavedProperties:
Expand Down
4 changes: 4 additions & 0 deletions Cardboard/DemoScene/Teleport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public void Reset() {
transform.localPosition = startingPosition;
}

public void ToggleVRMode() {
Cardboard.SDK.VRModeEnabled = !Cardboard.SDK.VRModeEnabled;
}

public void TeleportRandomly() {
Vector3 direction = Random.onUnitSphere;
direction.y = Mathf.Clamp(direction.y, 0.5f, 1f);
Expand Down
148 changes: 72 additions & 76 deletions Cardboard/Editor/CardboardEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,118 +15,114 @@
using System.Collections;
using UnityEditor;
using UnityEngine;
using UnityEditor.Callbacks;

[CustomEditor(typeof(Cardboard))]
[InitializeOnLoad]
public class CardboardEditor : Editor {
GUIContent tapIsTriggerLabel = new GUIContent("Tap Is Trigger",
"Allow screen taps and mouse clicks to emulate the magnet trigger.");
#if UNITY_IOS
GUIContent syncWithCardboardLabel = new GUIContent("Sync with Cardboard App",
"Enables the 'Sync with Google Cardboard' slider in the viewer settings dialog.");
#endif

GUIContent distortionCorrectionLabel = new GUIContent("Distortion Correction",
"Whether distortion correction is performed the SDK.");

GUIContent vrModeLabel = new GUIContent("VR Mode Enabled",
"Sets whether VR mode is enabled.");

GUIContent alignmentMarkerLabel = new GUIContent("Alignment Marker",
"Whether to draw the alignment marker. The marker is a vertical line that splits " +
"the viewport in half, designed to help users align the screen with the Cardboard.");
"Whether to draw the alignment marker. The marker is a vertical line that splits " +
"the viewport in half, designed to help users align the screen with the Cardboard.");

GUIContent settingsButtonLabel = new GUIContent("Settings Button",
"Whether to draw the settings button. The settings button opens the " +
"Google Cardboard app to allow the user to configure their individual " +
"settings and Cardboard headset parameters.");
"Whether to draw the settings button. The settings button opens the " +
"Google Cardboard app to allow the user to configure their individual " +
"settings and Cardboard headset parameters.");

GUIContent vrModeEnabledLabel = new GUIContent("VR Mode Enabled",
"Explicitly set whether VR mode is enabled. Clears the Auto Enable VR setting.");

GUIContent neckModelScaleLabel = new GUIContent("Neck Model Scale",
"The scale factor of the builtin neck model [0..1]. To disable, set to 0.");
GUIContent autoDriftCorrectionLabel = new GUIContent("Auto Drift Correction",
"When enabled, drift in the gyro readings is estimated and removed.");

GUIContent backButtonExitsAppLabel = new GUIContent("Back Button Exits App",
"Whether tapping the back button exits the app.");
GUIContent tapIsTriggerLabel = new GUIContent("Tap Is Trigger",
"Whether screen taps are treated as trigger events.");

GUIContent autoDriftCorrectionLabel = new GUIContent("Auto Drift Correction",
"When enabled, drift in the gyro readings is estimated and removed. Currently only " +
"works on Android.");
GUIContent neckModelScaleLabel = new GUIContent("Neck Model Scale",
"The scale factor of the builtin neck model [0..1]. To disable, set to 0.");

GUIContent editorSettingsLabel = new GUIContent("Editor Mock Settings",
"Controls for the in-editor emulation of Cardboard.");
"Controls for the in-editor emulation of Cardboard.");

GUIContent autoUntiltHeadLabel = new GUIContent("Auto Untilt Head",
"When enabled, just release Ctrl to untilt the head.");
"When enabled, just release Ctrl to untilt the head.");

GUIContent simulateDistortionLabel = new GUIContent("Simulate Distortion Correction",
"Whether to perform distortion correction in the editor.");

GUIContent screenSizeLabel = new GUIContent("Screen Size",
"The screen size to emulate.");
"The screen size to emulate.");

GUIContent deviceTypeLabel = new GUIContent("Device Type",
"The Cardboard device type to emulate.");

GUIContent simulateDistortionLabel = new GUIContent("Simulate Distortion Correction",
"Whether to perform distortion correction in the editor.");
"The Cardboard device type to emulate.");

public override void OnInspectorGUI() {
GUI.changed = false;

DrawDefaultInspector();

Cardboard cardboard = (Cardboard)target;

bool newTapIsTrigger = EditorGUILayout.Toggle(tapIsTriggerLabel, cardboard.TapIsTrigger);
if (newTapIsTrigger != cardboard.TapIsTrigger) {
cardboard.TapIsTrigger = newTapIsTrigger;
}

bool newEnableAlignmentMarkder =
EditorGUILayout.Toggle(alignmentMarkerLabel, cardboard.EnableAlignmentMarker);
if (newEnableAlignmentMarkder != cardboard.EnableAlignmentMarker) {
cardboard.EnableAlignmentMarker = newEnableAlignmentMarkder;
}

bool newEnableSettingsButton =
EditorGUILayout.Toggle(settingsButtonLabel, cardboard.EnableSettingsButton);
if (newEnableSettingsButton != cardboard.EnableSettingsButton) {
cardboard.EnableSettingsButton = newEnableSettingsButton;
}

bool newAutoDriftCorrection =
EditorGUILayout.Toggle(autoDriftCorrectionLabel, cardboard.AutoDriftCorrection);
if (newAutoDriftCorrection != cardboard.AutoDriftCorrection) {
cardboard.AutoDriftCorrection = newAutoDriftCorrection;
}

bool newVRModeEnabled = EditorGUILayout.Toggle(vrModeEnabledLabel, cardboard.VRModeEnabled);
if (newVRModeEnabled != cardboard.VRModeEnabled) {
cardboard.VRModeEnabled = newVRModeEnabled;
}

float newNeckModelScale = EditorGUILayout.Slider(neckModelScaleLabel,
cardboard.NeckModelScale, 0, 1);
if (!Mathf.Approximately(newNeckModelScale, cardboard.NeckModelScale)) {
cardboard.NeckModelScale = newNeckModelScale;
}

cardboard.BackButtonExitsApp =
EditorGUILayout.Toggle(backButtonExitsAppLabel, cardboard.BackButtonExitsApp);
#if UNITY_IOS
cardboard.SyncWithCardboardApp =
EditorGUILayout.Toggle(syncWithCardboardLabel, cardboard.SyncWithCardboardApp);
#endif
cardboard.VRModeEnabled =
EditorGUILayout.Toggle(vrModeLabel, cardboard.VRModeEnabled);
cardboard.DistortionCorrection =
EditorGUILayout.Toggle(distortionCorrectionLabel, cardboard.DistortionCorrection);
cardboard.EnableAlignmentMarker =
EditorGUILayout.Toggle(alignmentMarkerLabel, cardboard.EnableAlignmentMarker);
cardboard.EnableSettingsButton =
EditorGUILayout.Toggle(settingsButtonLabel, cardboard.EnableSettingsButton);
cardboard.AutoDriftCorrection =
EditorGUILayout.Toggle(autoDriftCorrectionLabel, cardboard.AutoDriftCorrection);
cardboard.TapIsTrigger =
EditorGUILayout.Toggle(tapIsTriggerLabel, cardboard.TapIsTrigger);
cardboard.NeckModelScale =
EditorGUILayout.Slider(neckModelScaleLabel, cardboard.NeckModelScale, 0, 1);

EditorGUILayout.Separator();

EditorGUILayout.LabelField(editorSettingsLabel);

cardboard.autoUntiltHead = EditorGUILayout.Toggle(autoUntiltHeadLabel,
cardboard.autoUntiltHead);

cardboard.autoUntiltHead =
EditorGUILayout.Toggle(autoUntiltHeadLabel, cardboard.autoUntiltHead);
cardboard.simulateDistortionCorrection =
EditorGUILayout.Toggle(simulateDistortionLabel, cardboard.simulateDistortionCorrection);

cardboard.screenSize = (CardboardProfile.ScreenSizes)
EditorGUILayout.EnumPopup(screenSizeLabel, cardboard.screenSize);

cardboard.deviceType = (CardboardProfile.DeviceTypes)
EditorGUILayout.EnumPopup(deviceTypeLabel, cardboard.deviceType);
cardboard.ScreenSize = (CardboardProfile.ScreenSizes)
EditorGUILayout.EnumPopup(screenSizeLabel, cardboard.ScreenSize);
cardboard.DeviceType = (CardboardProfile.DeviceTypes)
EditorGUILayout.EnumPopup(deviceTypeLabel, cardboard.DeviceType);

if (GUI.changed) {
EditorUtility.SetDirty(cardboard);
}
}

static CardboardEditor() {
EditorUserBuildSettings.activeBuildTargetChanged += CheckGraphicsAPI;
}

[PostProcessBuild]
public static void CheckGraphicsAPI(BuildTarget target, string path) {
CheckGraphicsAPI();
}

if (EditorApplication.isPlaying) {
bool newInCardboard = EditorGUILayout.Toggle("Is In Cardboard", cardboard.InCardboard);
if (newInCardboard != cardboard.InCardboard) {
cardboard.SetInCardboard(newInCardboard); // Takes effect at end of frame.
}
private static void CheckGraphicsAPI() {
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iPhone
&& !Application.isPlaying
&& Object.FindObjectOfType<Cardboard>() != null
&& PlayerSettings.targetIOSGraphics != TargetIOSGraphics.OpenGLES_2_0
&& PlayerSettings.targetIOSGraphics != TargetIOSGraphics.OpenGLES_3_0) {
Debug.LogWarning("iOS Graphics API should be set to OpenGL for best distortion-"
+ "correction performance in Cardboard.");
}
}
}
Loading

0 comments on commit dc29f68

Please sign in to comment.