From 9996893cd2a95d5e89739f6da2760b07c8620e4b Mon Sep 17 00:00:00 2001 From: Jlim Date: Sat, 30 Oct 2021 01:13:47 -0400 Subject: [PATCH] Ok Timer et temtative Fix Teleportation --- .../Locomotion/Materials/TeleportLaser.mat | 8 +- .../Locomotion/Scripts/LocomotionTeleport.cs | 6 +- Assets/Scenes/MainGame.unity | 184 +++++++++++++++++- Assets/Scripts/Timer.cs | 50 +++++ Assets/Scripts/Timer.cs.meta | 11 ++ 5 files changed, 250 insertions(+), 9 deletions(-) create mode 100644 Assets/Scripts/Timer.cs create mode 100644 Assets/Scripts/Timer.cs.meta diff --git a/Assets/Oculus/SampleFramework/Core/Locomotion/Materials/TeleportLaser.mat b/Assets/Oculus/SampleFramework/Core/Locomotion/Materials/TeleportLaser.mat index 306941e..e632bb6 100644 --- a/Assets/Oculus/SampleFramework/Core/Locomotion/Materials/TeleportLaser.mat +++ b/Assets/Oculus/SampleFramework/Core/Locomotion/Materials/TeleportLaser.mat @@ -4,8 +4,9 @@ Material: serializedVersion: 6 m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_Name: TeleportLaser m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} m_ShaderKeywords: _EMISSION @@ -72,5 +73,6 @@ Material: - _UVSec: 0 - _ZWrite: 1 m_Colors: - - _Color: {r: 0, g: 1, b: 0, a: 1} + - _Color: {r: 1, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Oculus/SampleFramework/Core/Locomotion/Scripts/LocomotionTeleport.cs b/Assets/Oculus/SampleFramework/Core/Locomotion/Scripts/LocomotionTeleport.cs index deb5924..34943a5 100644 --- a/Assets/Oculus/SampleFramework/Core/Locomotion/Scripts/LocomotionTeleport.cs +++ b/Assets/Oculus/SampleFramework/Core/Locomotion/Scripts/LocomotionTeleport.cs @@ -761,6 +761,8 @@ public class LocomotionTeleport : MonoBehaviour /// public event Action Teleported; + + public Transform player; /// /// Perform the actual teleport. /// Note that warp transitions do not call this function and instead moves the game object @@ -770,7 +772,7 @@ public class LocomotionTeleport : MonoBehaviour { var character = LocomotionController.CharacterController; character.enabled = false; - var characterTransform = character.transform; + var characterTransform = player; var destTransform = _teleportDestination.OrientationIndicator; Vector3 destPosition = destTransform.position; @@ -785,7 +787,7 @@ public class LocomotionTeleport : MonoBehaviour #endif if (Teleported != null) { - Teleported(characterTransform, destPosition, destRotation); + Teleported(player, destPosition, destRotation); } characterTransform.position = destPosition; diff --git a/Assets/Scenes/MainGame.unity b/Assets/Scenes/MainGame.unity index 0fdb16e..ef4f0d5 100644 --- a/Assets/Scenes/MainGame.unity +++ b/Assets/Scenes/MainGame.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0.18028334, g: 0.2257134, b: 0.30692226, a: 1} + m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -877,6 +877,7 @@ MonoBehaviour: UseCharacterCollisionData: 0 AimCollisionRadius: 0 AimCollisionHeight: 0 + player: {fileID: 0} --- !u!114 &223974235 MonoBehaviour: m_ObjectHideFlags: 0 @@ -3420,6 +3421,115 @@ BoxCollider: serializedVersion: 2 m_Size: {x: 2.0196953, y: 0.2, z: 2.0206933} m_Center: {x: 0.0039343834, y: 0, z: 0.012269765} +--- !u!1 &694129166 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 694129170} + - component: {fileID: 694129169} + - component: {fileID: 694129168} + - component: {fileID: 694129167} + m_Layer: 0 + m_Name: Timer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &694129167 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 694129166} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 10905daa68280fb409fb8b12d42ec16f, type: 3} + m_Name: + m_EditorClassIdentifier: + text: {fileID: 694129168} +--- !u!102 &694129168 +TextMesh: + serializedVersion: 3 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 694129166} + m_Text: Hello World + m_OffsetZ: 0 + m_CharacterSize: 1 + m_LineSpacing: 1 + m_Anchor: 0 + m_Alignment: 0 + m_TabSize: 4 + m_FontSize: 100 + m_FontStyle: 0 + m_RichText: 1 + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_Color: + serializedVersion: 2 + rgba: 4294967295 +--- !u!23 &694129169 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 694129166} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!4 &694129170 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 694129166} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 7.735, y: 1.756, z: 11.63} + m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &705507993 GameObject: m_ObjectHideFlags: 0 @@ -7499,6 +7609,72 @@ Transform: m_Father: {fileID: 1471131253} m_RootOrder: 19 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1618949543 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1618949546} + - component: {fileID: 1618949545} + - component: {fileID: 1618949544} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1618949544 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1618949543} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &1618949545 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1618949543} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &1618949546 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1618949543} + 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: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1620706918 PrefabInstance: m_ObjectHideFlags: 0 @@ -8524,15 +8700,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 400006, guid: ce816f2e6abb0504092c23ed9b970dfd, type: 3} propertyPath: m_LocalPosition.x - value: 0.057 + value: 0.008 objectReference: {fileID: 0} - target: {fileID: 400006, guid: ce816f2e6abb0504092c23ed9b970dfd, type: 3} propertyPath: m_LocalPosition.y - value: 1.967 + value: 1.059 objectReference: {fileID: 0} - target: {fileID: 400006, guid: ce816f2e6abb0504092c23ed9b970dfd, type: 3} propertyPath: m_LocalPosition.z - value: -0.64 + value: 0.67 objectReference: {fileID: 0} - target: {fileID: 400006, guid: ce816f2e6abb0504092c23ed9b970dfd, type: 3} propertyPath: m_LocalRotation.w diff --git a/Assets/Scripts/Timer.cs b/Assets/Scripts/Timer.cs new file mode 100644 index 0000000..404cd16 --- /dev/null +++ b/Assets/Scripts/Timer.cs @@ -0,0 +1,50 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class Timer : MonoBehaviour +{ + private float time { get; set; } + private bool timerStop { get; set; } + + [SerializeField] + private TextMesh text; + + private Coroutine timerRoutine; + + // Start is called before the first frame update + void Start() + { + time = 0; + Coroutine timerRoutine = StartCoroutine("TimerExecute"); + } + + private void FixedUpdate() + { + + + } + + public void Stop() + { + timerStop = true; + StopCoroutine(timerRoutine); + + } + + IEnumerator TimerExecute() + { + while (true) + { + if (!timerStop) + { + time += 0.1f; + if (text != null) + text.text = ""+ (Mathf.Round(time * 10) * 0.1f).ToString("F1"); + yield return new WaitForSeconds(.1f); + } + } + + } +} diff --git a/Assets/Scripts/Timer.cs.meta b/Assets/Scripts/Timer.cs.meta new file mode 100644 index 0000000..0315524 --- /dev/null +++ b/Assets/Scripts/Timer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 10905daa68280fb409fb8b12d42ec16f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: