From 0e6db50b316a68bf5c4dc13ff7135454782f8609 Mon Sep 17 00:00:00 2001 From: JScott Date: Thu, 10 Mar 2016 13:59:16 -0800 Subject: [PATCH] Rely on Google's prefab instead of duplicating it Kudos to Romain for a code review and pointing out my oddity --- .../DemoScenes/ControlsDemo.unity | 4 + CardboardControl/DemoScenes/WalkingDemo.unity | 8 ++ .../Prefabs/CardboardControlManager.prefab | 15 +++- .../Prefabs/Resources/CardboardReticle.prefab | 81 ------------------- CardboardControl/Scripts/CardboardControl.cs | 2 +- .../Scripts/CardboardControlReticle.cs | 1 + 6 files changed, 25 insertions(+), 86 deletions(-) delete mode 100644 CardboardControl/Prefabs/Resources/CardboardReticle.prefab diff --git a/CardboardControl/DemoScenes/ControlsDemo.unity b/CardboardControl/DemoScenes/ControlsDemo.unity index 2cef973..cf75d86 100644 --- a/CardboardControl/DemoScenes/ControlsDemo.unity +++ b/CardboardControl/DemoScenes/ControlsDemo.unity @@ -200,6 +200,10 @@ Prefab: propertyPath: layerMask.m_Bits value: 256 objectReference: {fileID: 0} + - target: {fileID: 11447888, guid: 652814e1e9ffe134aa9b9c61f31fb762, type: 2} + propertyPath: prefab + value: + objectReference: {fileID: 171526, guid: 60270cf52a5e94998a5a335989159738, type: 2} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 652814e1e9ffe134aa9b9c61f31fb762, type: 2} m_IsPrefabParent: 0 diff --git a/CardboardControl/DemoScenes/WalkingDemo.unity b/CardboardControl/DemoScenes/WalkingDemo.unity index 60829e3..fcf0edb 100644 --- a/CardboardControl/DemoScenes/WalkingDemo.unity +++ b/CardboardControl/DemoScenes/WalkingDemo.unity @@ -200,6 +200,14 @@ Prefab: propertyPath: layerMask.m_Bits value: 256 objectReference: {fileID: 0} + - target: {fileID: 11447888, guid: 652814e1e9ffe134aa9b9c61f31fb762, type: 2} + propertyPath: reticle + value: + objectReference: {fileID: 171526, guid: 60270cf52a5e94998a5a335989159738, type: 2} + - target: {fileID: 11447888, guid: 652814e1e9ffe134aa9b9c61f31fb762, type: 2} + propertyPath: prefab + value: + objectReference: {fileID: 171526, guid: 60270cf52a5e94998a5a335989159738, type: 2} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 652814e1e9ffe134aa9b9c61f31fb762, type: 2} m_IsPrefabParent: 0 diff --git a/CardboardControl/Prefabs/CardboardControlManager.prefab b/CardboardControl/Prefabs/CardboardControlManager.prefab index d6db875..d492903 100644 --- a/CardboardControl/Prefabs/CardboardControlManager.prefab +++ b/CardboardControl/Prefabs/CardboardControlManager.prefab @@ -43,9 +43,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4e96b5b0d55c6dd48846315b5654102b, type: 3} m_Name: m_EditorClassIdentifier: - reticlePrefab: {fileID: 100896, guid: 4e70f128821fbd44397a839b4080d103, type: 2} - fadeTime: .600000024 + fadeTime: 0.6 startHidden: 1 + layerMask: + serializedVersion: 2 + m_Bits: 4294967291 + prefab: {fileID: 171526, guid: 60270cf52a5e94998a5a335989159738, type: 2} --- !u!114 &11455312 MonoBehaviour: m_ObjectHideFlags: 1 @@ -80,7 +83,7 @@ MonoBehaviour: gaze: {fileID: 11455312} box: {fileID: 11481902} reticle: {fileID: 0} - eventCooldown: .200000003 + eventCooldown: 0.2 --- !u!114 &11474088 MonoBehaviour: m_ObjectHideFlags: 1 @@ -92,7 +95,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ff5c5b6d52fa37e48991bdffd4b620e5, type: 3} m_Name: m_EditorClassIdentifier: - clickSpeedThreshold: .400000006 + clickSpeedThreshold: 0.4 useEventCooldowns: 1 vibrateOnDown: 0 vibrateOnUp: 0 @@ -158,6 +161,10 @@ Prefab: propertyPath: reticlePrefab value: objectReference: {fileID: 100896, guid: 4e70f128821fbd44397a839b4080d103, type: 2} + - target: {fileID: 0} + propertyPath: prefab + value: + objectReference: {fileID: 171526, guid: 60270cf52a5e94998a5a335989159738, type: 2} m_RemovedComponents: [] m_ParentPrefab: {fileID: 0} m_RootGameObject: {fileID: 110264} diff --git a/CardboardControl/Prefabs/Resources/CardboardReticle.prefab b/CardboardControl/Prefabs/Resources/CardboardReticle.prefab deleted file mode 100644 index 8a627d1..0000000 --- a/CardboardControl/Prefabs/Resources/CardboardReticle.prefab +++ /dev/null @@ -1,81 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &100896 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 4 - m_Component: - - 4: {fileID: 488074} - - 114: {fileID: 11434670} - - 23: {fileID: 2343286} - m_Layer: 2 - m_Name: CardboardReticle - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &488074 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100896} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 ---- !u!23 &2343286 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100896} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_Materials: - - {fileID: 2100000, guid: 4cb1460f617514a888f47071314ccdae, type: 2} - m_SubsetIndices: - m_StaticBatchRoot: {fileID: 0} - m_UseLightProbes: 0 - m_ReflectionProbeUsage: 1 - m_ProbeAnchor: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: .5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingOrder: 0 ---- !u!114 &11434670 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100896} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 66c63f8350cb04a2683f8606cc8d36f7, type: 3} - m_Name: - m_EditorClassIdentifier: - reticleSegments: 20 - reticleGrowthSpeed: 8 ---- !u!1001 &100100000 -Prefab: - m_ObjectHideFlags: 1 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: [] - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 0} - m_RootGameObject: {fileID: 100896} - m_IsPrefabParent: 1 diff --git a/CardboardControl/Scripts/CardboardControl.cs b/CardboardControl/Scripts/CardboardControl.cs index f0029e7..ecdafee 100644 --- a/CardboardControl/Scripts/CardboardControl.cs +++ b/CardboardControl/Scripts/CardboardControl.cs @@ -70,7 +70,7 @@ private void InstantiateCardboardSDKReticleObject() { gameObject.AddComponent(); Camera.main.gameObject.AddComponent(); // The object itself - GameObject reticlePrefab = Instantiate(Resources.Load("CardboardReticle")) as GameObject; + GameObject reticlePrefab = Instantiate(reticle.prefab) as GameObject; reticlePrefab.transform.parent = Camera.main.transform; reticlePrefab.transform.localPosition = Vector3.zero; reticlePrefab.transform.localEulerAngles = Vector3.zero; diff --git a/CardboardControl/Scripts/CardboardControlReticle.cs b/CardboardControl/Scripts/CardboardControlReticle.cs index da44d29..4c59214 100644 --- a/CardboardControl/Scripts/CardboardControlReticle.cs +++ b/CardboardControl/Scripts/CardboardControlReticle.cs @@ -5,6 +5,7 @@ public class CardboardControlReticle : MonoBehaviour { public float fadeTime = 0.6f; public bool startHidden = true; public LayerMask layerMask = Physics.DefaultRaycastLayers; + public GameObject prefab; private GameObject reticle; private ColorFade colorFade = new ColorFade();