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

Commit dc29f68

Browse files
committed
Version 0.5
1 parent 3a9f4cb commit dc29f68

29 files changed

+3770
-967
lines changed

CHANGELOG

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,16 @@ v0.4.10 (4/16/2015):
5353
- Fixed CardboardGUI's Head property in the Legacy demo scene.
5454
- Fixed the neck model Z offset in the Editor.
5555
- Fixed a bug in CardboardEditor which failed to save the Editor-only settings.
56+
57+
v0.5 (5/28/2015):
58+
- The iOS build platform is now supported.
59+
- Added a new C++ native code implementation for head tracking and distortion correction.
60+
- The Java-based native code implementation has been moved to the Legacy folder.
61+
- Refactored Cardboard.cs into a front-end Unity API and a back-end VRDevice class.
62+
- VRDevice implementations provided for Android, iOS, and Unity editor.
63+
- Some Cardboard properties have been renamed (but the old names still work).
64+
- Added a Tilt event for when the viewer is turned on its side.
65+
- Added C# events to Cardboard for responding to Trigger and Tilt events.
66+
- Added more phone and viewer profiles to the in-editor simulation menus.
67+
- If native code distortion correction is not supported, fall back to using an Image Effect.
68+
- If native code UI layer is not supported, fall back to rendering it in Unity.

Cardboard/DemoScene/DemoScene.unity

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,14 @@ Prefab:
390390
propertyPath: neckModelScale
391391
value: 1
392392
objectReference: {fileID: 0}
393+
- target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2}
394+
propertyPath: UseUnityRemoteInput
395+
value: 0
396+
objectReference: {fileID: 0}
397+
- target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2}
398+
propertyPath: deviceType
399+
value: 0
400+
objectReference: {fileID: 0}
393401
m_RemovedComponents: []
394402
m_ParentPrefab: {fileID: 100100000, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2}
395403
m_RootGameObject: {fileID: 1427108206}
@@ -893,7 +901,7 @@ MonoBehaviour:
893901
m_OnClick:
894902
m_PersistentCalls:
895903
m_Calls:
896-
- m_Target: {fileID: 1427108208}
904+
- m_Target: {fileID: 955127921}
897905
m_MethodName: ToggleVRMode
898906
m_Mode: 1
899907
m_Arguments:
@@ -2281,6 +2289,8 @@ MonoBehaviour:
22812289
m_Script: {fileID: 11500000, guid: f1578549c7fcc4f6fa1b063992091672, type: 3}
22822290
m_Name:
22832291
m_EditorClassIdentifier:
2292+
trackRotation: 1
2293+
trackPosition: 1
22842294
target: {fileID: 0}
22852295
updateEarly: 0
22862296
--- !u!1 &1427108206
@@ -2324,18 +2334,19 @@ MonoBehaviour:
23242334
m_Script: {fileID: 11500000, guid: a40b544b8c3553c40852ae7ad35a9343, type: 3}
23252335
m_Name:
23262336
m_EditorClassIdentifier:
2327-
nativeDistortionCorrection: 1
2337+
distortionCorrection: 1
23282338
vrModeEnabled: 1
23292339
enableAlignmentMarker: 1
23302340
enableSettingsButton: 1
2331-
tapIsTrigger: 1
2341+
TapIsTrigger: 1
23322342
neckModelScale: 1
2333-
backButtonExitsApp: 1
23342343
autoDriftCorrection: 1
2344+
syncWithCardboardApp: 0
23352345
autoUntiltHead: 1
2346+
simulateDistortionCorrection: 1
2347+
UseUnityRemoteInput: 0
23362348
screenSize: 0
23372349
deviceType: 0
2338-
simulateDistortionCorrection: 1
23392350
--- !u!1 &1499060387
23402351
GameObject:
23412352
m_ObjectHideFlags: 0

Cardboard/DemoScene/GroundPlane.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Material:
77
m_PrefabParentObject: {fileID: 0}
88
m_PrefabInternal: {fileID: 0}
99
m_Name: GroundPlane
10-
m_Shader: {fileID: 10703, guid: 0000000000000000f000000000000000, type: 0}
10+
m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0}
1111
m_ShaderKeywords: []
1212
m_CustomRenderQueue: -1
1313
m_SavedProperties:

Cardboard/DemoScene/Teleport.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public void Reset() {
3232
transform.localPosition = startingPosition;
3333
}
3434

35+
public void ToggleVRMode() {
36+
Cardboard.SDK.VRModeEnabled = !Cardboard.SDK.VRModeEnabled;
37+
}
38+
3539
public void TeleportRandomly() {
3640
Vector3 direction = Random.onUnitSphere;
3741
direction.y = Mathf.Clamp(direction.y, 0.5f, 1f);

Cardboard/Editor/CardboardEditor.cs

Lines changed: 72 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -15,118 +15,114 @@
1515
using System.Collections;
1616
using UnityEditor;
1717
using UnityEngine;
18+
using UnityEditor.Callbacks;
1819

1920
[CustomEditor(typeof(Cardboard))]
21+
[InitializeOnLoad]
2022
public class CardboardEditor : Editor {
21-
GUIContent tapIsTriggerLabel = new GUIContent("Tap Is Trigger",
22-
"Allow screen taps and mouse clicks to emulate the magnet trigger.");
23+
#if UNITY_IOS
24+
GUIContent syncWithCardboardLabel = new GUIContent("Sync with Cardboard App",
25+
"Enables the 'Sync with Google Cardboard' slider in the viewer settings dialog.");
26+
#endif
27+
28+
GUIContent distortionCorrectionLabel = new GUIContent("Distortion Correction",
29+
"Whether distortion correction is performed the SDK.");
30+
31+
GUIContent vrModeLabel = new GUIContent("VR Mode Enabled",
32+
"Sets whether VR mode is enabled.");
2333

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

2838
GUIContent settingsButtonLabel = new GUIContent("Settings Button",
29-
"Whether to draw the settings button. The settings button opens the " +
30-
"Google Cardboard app to allow the user to configure their individual " +
31-
"settings and Cardboard headset parameters.");
39+
"Whether to draw the settings button. The settings button opens the " +
40+
"Google Cardboard app to allow the user to configure their individual " +
41+
"settings and Cardboard headset parameters.");
3242

33-
GUIContent vrModeEnabledLabel = new GUIContent("VR Mode Enabled",
34-
"Explicitly set whether VR mode is enabled. Clears the Auto Enable VR setting.");
35-
36-
GUIContent neckModelScaleLabel = new GUIContent("Neck Model Scale",
37-
"The scale factor of the builtin neck model [0..1]. To disable, set to 0.");
43+
GUIContent autoDriftCorrectionLabel = new GUIContent("Auto Drift Correction",
44+
"When enabled, drift in the gyro readings is estimated and removed.");
3845

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

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

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

4955
GUIContent autoUntiltHeadLabel = new GUIContent("Auto Untilt Head",
50-
"When enabled, just release Ctrl to untilt the head.");
56+
"When enabled, just release Ctrl to untilt the head.");
57+
58+
GUIContent simulateDistortionLabel = new GUIContent("Simulate Distortion Correction",
59+
"Whether to perform distortion correction in the editor.");
5160

5261
GUIContent screenSizeLabel = new GUIContent("Screen Size",
53-
"The screen size to emulate.");
62+
"The screen size to emulate.");
5463

5564
GUIContent deviceTypeLabel = new GUIContent("Device Type",
56-
"The Cardboard device type to emulate.");
57-
58-
GUIContent simulateDistortionLabel = new GUIContent("Simulate Distortion Correction",
59-
"Whether to perform distortion correction in the editor.");
65+
"The Cardboard device type to emulate.");
6066

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

64-
DrawDefaultInspector();
65-
6670
Cardboard cardboard = (Cardboard)target;
6771

68-
bool newTapIsTrigger = EditorGUILayout.Toggle(tapIsTriggerLabel, cardboard.TapIsTrigger);
69-
if (newTapIsTrigger != cardboard.TapIsTrigger) {
70-
cardboard.TapIsTrigger = newTapIsTrigger;
71-
}
72-
73-
bool newEnableAlignmentMarkder =
74-
EditorGUILayout.Toggle(alignmentMarkerLabel, cardboard.EnableAlignmentMarker);
75-
if (newEnableAlignmentMarkder != cardboard.EnableAlignmentMarker) {
76-
cardboard.EnableAlignmentMarker = newEnableAlignmentMarkder;
77-
}
78-
79-
bool newEnableSettingsButton =
80-
EditorGUILayout.Toggle(settingsButtonLabel, cardboard.EnableSettingsButton);
81-
if (newEnableSettingsButton != cardboard.EnableSettingsButton) {
82-
cardboard.EnableSettingsButton = newEnableSettingsButton;
83-
}
84-
85-
bool newAutoDriftCorrection =
86-
EditorGUILayout.Toggle(autoDriftCorrectionLabel, cardboard.AutoDriftCorrection);
87-
if (newAutoDriftCorrection != cardboard.AutoDriftCorrection) {
88-
cardboard.AutoDriftCorrection = newAutoDriftCorrection;
89-
}
90-
91-
bool newVRModeEnabled = EditorGUILayout.Toggle(vrModeEnabledLabel, cardboard.VRModeEnabled);
92-
if (newVRModeEnabled != cardboard.VRModeEnabled) {
93-
cardboard.VRModeEnabled = newVRModeEnabled;
94-
}
95-
96-
float newNeckModelScale = EditorGUILayout.Slider(neckModelScaleLabel,
97-
cardboard.NeckModelScale, 0, 1);
98-
if (!Mathf.Approximately(newNeckModelScale, cardboard.NeckModelScale)) {
99-
cardboard.NeckModelScale = newNeckModelScale;
100-
}
101-
102-
cardboard.BackButtonExitsApp =
103-
EditorGUILayout.Toggle(backButtonExitsAppLabel, cardboard.BackButtonExitsApp);
72+
#if UNITY_IOS
73+
cardboard.SyncWithCardboardApp =
74+
EditorGUILayout.Toggle(syncWithCardboardLabel, cardboard.SyncWithCardboardApp);
75+
#endif
76+
cardboard.VRModeEnabled =
77+
EditorGUILayout.Toggle(vrModeLabel, cardboard.VRModeEnabled);
78+
cardboard.DistortionCorrection =
79+
EditorGUILayout.Toggle(distortionCorrectionLabel, cardboard.DistortionCorrection);
80+
cardboard.EnableAlignmentMarker =
81+
EditorGUILayout.Toggle(alignmentMarkerLabel, cardboard.EnableAlignmentMarker);
82+
cardboard.EnableSettingsButton =
83+
EditorGUILayout.Toggle(settingsButtonLabel, cardboard.EnableSettingsButton);
84+
cardboard.AutoDriftCorrection =
85+
EditorGUILayout.Toggle(autoDriftCorrectionLabel, cardboard.AutoDriftCorrection);
86+
cardboard.TapIsTrigger =
87+
EditorGUILayout.Toggle(tapIsTriggerLabel, cardboard.TapIsTrigger);
88+
cardboard.NeckModelScale =
89+
EditorGUILayout.Slider(neckModelScaleLabel, cardboard.NeckModelScale, 0, 1);
10490

10591
EditorGUILayout.Separator();
10692

10793
EditorGUILayout.LabelField(editorSettingsLabel);
10894

109-
cardboard.autoUntiltHead = EditorGUILayout.Toggle(autoUntiltHeadLabel,
110-
cardboard.autoUntiltHead);
111-
95+
cardboard.autoUntiltHead =
96+
EditorGUILayout.Toggle(autoUntiltHeadLabel, cardboard.autoUntiltHead);
11297
cardboard.simulateDistortionCorrection =
11398
EditorGUILayout.Toggle(simulateDistortionLabel, cardboard.simulateDistortionCorrection);
114-
115-
cardboard.screenSize = (CardboardProfile.ScreenSizes)
116-
EditorGUILayout.EnumPopup(screenSizeLabel, cardboard.screenSize);
117-
118-
cardboard.deviceType = (CardboardProfile.DeviceTypes)
119-
EditorGUILayout.EnumPopup(deviceTypeLabel, cardboard.deviceType);
99+
cardboard.ScreenSize = (CardboardProfile.ScreenSizes)
100+
EditorGUILayout.EnumPopup(screenSizeLabel, cardboard.ScreenSize);
101+
cardboard.DeviceType = (CardboardProfile.DeviceTypes)
102+
EditorGUILayout.EnumPopup(deviceTypeLabel, cardboard.DeviceType);
120103

121104
if (GUI.changed) {
122105
EditorUtility.SetDirty(cardboard);
123106
}
107+
}
108+
109+
static CardboardEditor() {
110+
EditorUserBuildSettings.activeBuildTargetChanged += CheckGraphicsAPI;
111+
}
112+
113+
[PostProcessBuild]
114+
public static void CheckGraphicsAPI(BuildTarget target, string path) {
115+
CheckGraphicsAPI();
116+
}
124117

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

0 commit comments

Comments
 (0)