From 67eac2c871deb1aabd919d559759afab061ab23d Mon Sep 17 00:00:00 2001 From: Romeeey <121696184+Romeeey@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:14:05 +0200 Subject: [PATCH 1/4] Runtime settings manager created --- Assets/GothicVR/Scripts/Settings.meta | 8 +++ .../Scripts/Settings/RuntimeSettings.cs | 67 +++++++++++++++++++ .../Scripts/Settings/RuntimeSettings.cs.meta | 11 +++ 3 files changed, 86 insertions(+) create mode 100644 Assets/GothicVR/Scripts/Settings.meta create mode 100644 Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs create mode 100644 Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs.meta diff --git a/Assets/GothicVR/Scripts/Settings.meta b/Assets/GothicVR/Scripts/Settings.meta new file mode 100644 index 000000000..e67cc14ff --- /dev/null +++ b/Assets/GothicVR/Scripts/Settings.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7183eb41aa9a0fb48a1cbea94e4a260d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs b/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs new file mode 100644 index 000000000..ed8bbefef --- /dev/null +++ b/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs @@ -0,0 +1,67 @@ +using GVR.Util; +using UnityEngine; +using GVR.Manager; +using UnityEngine.XR.Interaction.Toolkit; +using UnityEditor; + +namespace GVR.Debugging +{ + public class RuntimeSettings : SingletonBehaviour + { + public enum TurnType + { + ContinuousTurn, + SnapTurn + }; + + [Header("__________Movement__________")] + [Tooltip("Movement settings")] + public TurnType turntype; + + public GameObject locomotionsystem; + public ActionBasedSnapTurnProvider snapTurn; + public ActionBasedContinuousTurnProvider continuousTurn; + + public void OnValidate() + { + DropdownItemSelected(turntype); + } + + public void DropdownItemSelected(TurnType turntype) + { + switch (turntype) + { + case TurnType.ContinuousTurn: + EnableContinuousTurn(); + break; + case TurnType.SnapTurn: + default: + EnableSnapTurn(); + break; + } + } + + void EnableSnapTurn() + { + //PlayerPrefs.SetInt(ConstantsManager.I.turnSettingPlayerPref, 0); + + if (!locomotionsystem) + return; + + snapTurn.enabled = true; + continuousTurn.enabled = false; + } + + void EnableContinuousTurn() + { + //PlayerPrefs.SetInt(ConstantsManager.I.turnSettingPlayerPref, 1); + + if (!locomotionsystem) + return; + + snapTurn.enabled = false; + continuousTurn.enabled = true; + } + + } +} \ No newline at end of file diff --git a/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs.meta b/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs.meta new file mode 100644 index 000000000..40c91b659 --- /dev/null +++ b/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fa0feeef66d8e224f83e74bd5df49302 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 1d797278c3b24b2d473f3136625fde079d1cad9b Mon Sep 17 00:00:00 2001 From: Romeeey <121696184+Romeeey@users.noreply.github.com> Date: Tue, 24 Oct 2023 21:11:07 +0200 Subject: [PATCH 2/4] no message --- .../UI Element Prefabs/MainMenu.prefab | 11 ++-- .../UI Element Prefabs/VRPlayer.prefab | 4 +- Assets/GothicVR/Scenes/General.unity | 50 +++++++++++-------- .../{UI => Settings}/MoveSpeedController.cs | 0 .../MoveSpeedController.cs.meta | 0 .../Scripts/Settings/RuntimeSettings.cs | 36 +++++++++++-- .../TurnSettingDropdownController.cs | 0 .../TurnSettingDropdownController.cs.meta | 0 .../TurnSettingDropdownController_v2.cs | 36 +++++++++++++ .../TurnSettingDropdownController_v2.cs.meta | 11 ++++ 10 files changed, 116 insertions(+), 32 deletions(-) rename Assets/GothicVR/Scripts/{UI => Settings}/MoveSpeedController.cs (100%) rename Assets/GothicVR/Scripts/{UI => Settings}/MoveSpeedController.cs.meta (100%) rename Assets/GothicVR/Scripts/{UI => Settings}/TurnSettingDropdownController.cs (100%) rename Assets/GothicVR/Scripts/{UI => Settings}/TurnSettingDropdownController.cs.meta (100%) create mode 100644 Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs create mode 100644 Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs.meta diff --git a/Assets/GothicVR/Resources/Prefabs/UI Element Prefabs/MainMenu.prefab b/Assets/GothicVR/Resources/Prefabs/UI Element Prefabs/MainMenu.prefab index db2e1c167..53a67a9a2 100644 --- a/Assets/GothicVR/Resources/Prefabs/UI Element Prefabs/MainMenu.prefab +++ b/Assets/GothicVR/Resources/Prefabs/UI Element Prefabs/MainMenu.prefab @@ -1893,7 +1893,7 @@ GameObject: - component: {fileID: 7242628824849592837} - component: {fileID: 1485463712071812010} - component: {fileID: 5139670529807056872} - - component: {fileID: 6969592086016783357} + - component: {fileID: 6139376406399139866} m_Layer: 5 m_Name: TurnSettingDropdown m_TagString: Untagged @@ -2022,7 +2022,7 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] m_AlphaFadeSpeed: 0.15 ---- !u!114 &6969592086016783357 +--- !u!114 &6139376406399139866 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -2031,12 +2031,9 @@ MonoBehaviour: m_GameObject: {fileID: 2620367377614364553} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ef149701c0a67744b88eaf8a23a75f75, type: 3} + m_Script: {fileID: 11500000, guid: 25cafb487887685459ed02e2541a4070, type: 3} m_Name: m_EditorClassIdentifier: - locomotionsystem: {fileID: 0} - snapTurn: {fileID: 0} - continuousTurn: {fileID: 0} --- !u!1 &2696797225813865958 GameObject: m_ObjectHideFlags: 0 @@ -5534,7 +5531,7 @@ MonoBehaviour: MovementMenu: {fileID: 2970808030810714954} UIMenu: {fileID: 330079844024664551} moveSpeedController: {fileID: 5718367256005164722} - turnSettingDropdownController: {fileID: 6969592086016783357} + turnSettingDropdownController: {fileID: 0} --- !u!1 &5909829140847279542 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/GothicVR/Resources/Prefabs/UI Element Prefabs/VRPlayer.prefab b/Assets/GothicVR/Resources/Prefabs/UI Element Prefabs/VRPlayer.prefab index 6bbde166d..59fdb675e 100644 --- a/Assets/GothicVR/Resources/Prefabs/UI Element Prefabs/VRPlayer.prefab +++ b/Assets/GothicVR/Resources/Prefabs/UI Element Prefabs/VRPlayer.prefab @@ -1537,7 +1537,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 3286136462831979470} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 2213c36610e3b1c4bbf886810ed9db12, type: 3} m_Name: @@ -1579,7 +1579,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 3286136462831979470} - m_Enabled: 0 + m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 919e39492806b334982b6b84c90dd927, type: 3} m_Name: diff --git a/Assets/GothicVR/Scenes/General.unity b/Assets/GothicVR/Scenes/General.unity index 870840f83..6225d8081 100644 --- a/Assets/GothicVR/Scenes/General.unity +++ b/Assets/GothicVR/Scenes/General.unity @@ -136,10 +136,6 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 1353668847} m_Modifications: - - target: {fileID: 1762865631986952849, guid: 4600f492db92202478d7c53019a519d0, type: 3} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} - target: {fileID: 3286136461781483594, guid: 4600f492db92202478d7c53019a519d0, type: 3} propertyPath: m_Name value: VRPlayer @@ -184,14 +180,6 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 7775121018924269947, guid: 4600f492db92202478d7c53019a519d0, type: 3} - propertyPath: moveSpeedController - value: - objectReference: {fileID: 1263267812} - - target: {fileID: 7775121018924269947, guid: 4600f492db92202478d7c53019a519d0, type: 3} - propertyPath: turnSettingDropdownController - value: - objectReference: {fileID: 1263267811} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -199,26 +187,31 @@ PrefabInstance: m_SourcePrefab: {fileID: 100100000, guid: 4600f492db92202478d7c53019a519d0, type: 3} --- !u!114 &1263267811 stripped MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 2887344511092649167, guid: 4600f492db92202478d7c53019a519d0, type: 3} + m_CorrespondingSourceObject: {fileID: 3286136462831979465, guid: 4600f492db92202478d7c53019a519d0, type: 3} m_PrefabInstance: {fileID: 1263267810} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} + m_GameObject: {fileID: 1263267814} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ef149701c0a67744b88eaf8a23a75f75, type: 3} + m_Script: {fileID: 11500000, guid: 919e39492806b334982b6b84c90dd927, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &1263267812 stripped +--- !u!114 &1263267813 stripped MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 572703872717889920, guid: 4600f492db92202478d7c53019a519d0, type: 3} + m_CorrespondingSourceObject: {fileID: 3286136462831979467, guid: 4600f492db92202478d7c53019a519d0, type: 3} m_PrefabInstance: {fileID: 1263267810} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 + m_GameObject: {fileID: 1263267814} + m_Enabled: 0 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 31f5b2d8250c75e4aae94a1800dca71c, type: 3} + m_Script: {fileID: 11500000, guid: 2213c36610e3b1c4bbf886810ed9db12, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!1 &1263267814 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 3286136462831979470, guid: 4600f492db92202478d7c53019a519d0, type: 3} + m_PrefabInstance: {fileID: 1263267810} + m_PrefabAsset: {fileID: 0} --- !u!1 &1353668846 GameObject: m_ObjectHideFlags: 0 @@ -228,6 +221,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1353668847} + - component: {fileID: 1353668848} m_Layer: 0 m_Name: PlayerController m_TagString: Untagged @@ -251,6 +245,22 @@ Transform: - {fileID: 668062117} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1353668848 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1353668846} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fa0feeef66d8e224f83e74bd5df49302, type: 3} + m_Name: + m_EditorClassIdentifier: + turntype: 0 + locomotionsystem: {fileID: 1263267814} + snapTurn: {fileID: 1263267813} + continuousTurn: {fileID: 1263267811} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 diff --git a/Assets/GothicVR/Scripts/UI/MoveSpeedController.cs b/Assets/GothicVR/Scripts/Settings/MoveSpeedController.cs similarity index 100% rename from Assets/GothicVR/Scripts/UI/MoveSpeedController.cs rename to Assets/GothicVR/Scripts/Settings/MoveSpeedController.cs diff --git a/Assets/GothicVR/Scripts/UI/MoveSpeedController.cs.meta b/Assets/GothicVR/Scripts/Settings/MoveSpeedController.cs.meta similarity index 100% rename from Assets/GothicVR/Scripts/UI/MoveSpeedController.cs.meta rename to Assets/GothicVR/Scripts/Settings/MoveSpeedController.cs.meta diff --git a/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs b/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs index ed8bbefef..5e911b9c0 100644 --- a/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs +++ b/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs @@ -2,7 +2,6 @@ using UnityEngine; using GVR.Manager; using UnityEngine.XR.Interaction.Toolkit; -using UnityEditor; namespace GVR.Debugging { @@ -16,12 +15,18 @@ public enum TurnType [Header("__________Movement__________")] [Tooltip("Movement settings")] + public TurnType turntype; public GameObject locomotionsystem; public ActionBasedSnapTurnProvider snapTurn; public ActionBasedContinuousTurnProvider continuousTurn; + void Awake() + { + //TurnTypeSelected(PlayerPrefs.GetInt(ConstantsManager.turnSettingPlayerPref)); + } + public void OnValidate() { DropdownItemSelected(turntype); @@ -43,7 +48,7 @@ public void DropdownItemSelected(TurnType turntype) void EnableSnapTurn() { - //PlayerPrefs.SetInt(ConstantsManager.I.turnSettingPlayerPref, 0); + SaveIntegerSettingsToPlayerPrefs(ConstantsManager.turnSettingPlayerPref, 0); if (!locomotionsystem) return; @@ -54,7 +59,7 @@ void EnableSnapTurn() void EnableContinuousTurn() { - //PlayerPrefs.SetInt(ConstantsManager.I.turnSettingPlayerPref, 1); + SaveIntegerSettingsToPlayerPrefs(ConstantsManager.turnSettingPlayerPref, 1); if (!locomotionsystem) return; @@ -63,5 +68,30 @@ void EnableContinuousTurn() continuousTurn.enabled = true; } + void TurnTypeSelected(int value) + { + switch (value) + { + case 1: + turntype = TurnType.ContinuousTurn; + break; + case 0: + default: + turntype = TurnType.SnapTurn; + break; + } + } + + void SaveIntegerSettingsToPlayerPrefs(string playerPrefEntry, int settingsValue) + { + PlayerPrefs.SetInt(playerPrefEntry, settingsValue); + } + + public static int LoadSettingsFromPlayerPrefs(string playerPrefEntry) + { + int playerPrefValue = PlayerPrefs.GetInt(playerPrefEntry); + return playerPrefValue; + } + } } \ No newline at end of file diff --git a/Assets/GothicVR/Scripts/UI/TurnSettingDropdownController.cs b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController.cs similarity index 100% rename from Assets/GothicVR/Scripts/UI/TurnSettingDropdownController.cs rename to Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController.cs diff --git a/Assets/GothicVR/Scripts/UI/TurnSettingDropdownController.cs.meta b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController.cs.meta similarity index 100% rename from Assets/GothicVR/Scripts/UI/TurnSettingDropdownController.cs.meta rename to Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController.cs.meta diff --git a/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs new file mode 100644 index 000000000..1ddc8018d --- /dev/null +++ b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs @@ -0,0 +1,36 @@ +using TMPro; +using UnityEngine; +using GVR.Debugging; +using GVR.Manager; + +public class TurnSettingDropdownController_v2 : MonoBehaviour +{ + private RuntimeSettings runtimeSettings; + + void Awake() + { + + runtimeSettings.turntype = RuntimeSettings.TurnType.ContinuousTurn; + Debug.Log(runtimeSettings.turntype.ToString()); + + var dropdown = transform.GetComponent(); + dropdown.onValueChanged.AddListener(DropdownItemSelected); + + dropdown.value = RuntimeSettings.LoadSettingsFromPlayerPrefs(ConstantsManager.turnSettingPlayerPref); + DropdownItemSelected(dropdown.value); + } + + public void DropdownItemSelected(int value) + { + switch (value) + { + case 1: + runtimeSettings.turntype = RuntimeSettings.TurnType.ContinuousTurn; + break; + case 0: + default: + runtimeSettings.turntype = RuntimeSettings.TurnType.SnapTurn; + break; + } + } +} diff --git a/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs.meta b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs.meta new file mode 100644 index 000000000..8506b78eb --- /dev/null +++ b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 25cafb487887685459ed02e2541a4070 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From cd62e86a76ff247fd2549d52d99fc7a581269a99 Mon Sep 17 00:00:00 2001 From: Romeeey <121696184+Romeeey@users.noreply.github.com> Date: Mon, 6 Nov 2023 15:33:00 +0100 Subject: [PATCH 3/4] no message --- Assets/GothicVR/Scenes/General.unity | 6 ++- .../Scripts/Settings/RuntimeSettings.cs | 50 ++++++++++--------- .../TurnSettingDropdownController_v2.cs | 10 +--- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Assets/GothicVR/Scenes/General.unity b/Assets/GothicVR/Scenes/General.unity index 6225d8081..d1f16a30d 100644 --- a/Assets/GothicVR/Scenes/General.unity +++ b/Assets/GothicVR/Scenes/General.unity @@ -136,6 +136,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 1353668847} m_Modifications: + - target: {fileID: 2133138095488065320, guid: 4600f492db92202478d7c53019a519d0, type: 3} + propertyPath: settingsManager + value: + objectReference: {fileID: 1353668846} - target: {fileID: 3286136461781483594, guid: 4600f492db92202478d7c53019a519d0, type: 3} propertyPath: m_Name value: VRPlayer @@ -257,7 +261,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: fa0feeef66d8e224f83e74bd5df49302, type: 3} m_Name: m_EditorClassIdentifier: - turntype: 0 + turntypeUI: 0 locomotionsystem: {fileID: 1263267814} snapTurn: {fileID: 1263267813} continuousTurn: {fileID: 1263267811} diff --git a/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs b/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs index 5e911b9c0..417f2551d 100644 --- a/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs +++ b/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs @@ -2,46 +2,58 @@ using UnityEngine; using GVR.Manager; using UnityEngine.XR.Interaction.Toolkit; +using UnityEngine.SceneManagement; namespace GVR.Debugging { public class RuntimeSettings : SingletonBehaviour { public enum TurnType - { - ContinuousTurn, - SnapTurn + { + SnapTurn, + ContinuousTurn }; [Header("__________Movement__________")] [Tooltip("Movement settings")] - public TurnType turntype; + public static TurnType turntype; + public TurnType turntypeUI; public GameObject locomotionsystem; public ActionBasedSnapTurnProvider snapTurn; public ActionBasedContinuousTurnProvider continuousTurn; - void Awake() + protected override void Awake() { - //TurnTypeSelected(PlayerPrefs.GetInt(ConstantsManager.turnSettingPlayerPref)); + Debug.Log("Initial PlayerPref: " + PlayerPrefs.GetInt(ConstantsManager.turnSettingPlayerPref).ToString()); + base.Awake(); + turntypeUI = (TurnType)PlayerPrefs.GetInt(ConstantsManager.turnSettingPlayerPref); + Debug.Log(PlayerPrefs.GetInt(ConstantsManager.turnSettingPlayerPref).ToString()); + Debug.Log(turntypeUI.ToString()); + turntype = turntypeUI; + DropdownItemSelected(turntypeUI); } - public void OnValidate() +#if UNITY_EDITOR + void OnValidate() { - DropdownItemSelected(turntype); + DropdownItemSelected(turntypeUI); } +#endif - public void DropdownItemSelected(TurnType turntype) + public void DropdownItemSelected(TurnType turntypeUI) { - switch (turntype) + switch(turntypeUI) { case TurnType.ContinuousTurn: EnableContinuousTurn(); + Debug.Log("Cont"); break; case TurnType.SnapTurn: default: EnableSnapTurn(); + Debug.Log("Snap"); break; } } @@ -49,37 +61,27 @@ public void DropdownItemSelected(TurnType turntype) void EnableSnapTurn() { SaveIntegerSettingsToPlayerPrefs(ConstantsManager.turnSettingPlayerPref, 0); + Debug.Log("Saved: " + 0); if (!locomotionsystem) return; snapTurn.enabled = true; continuousTurn.enabled = false; + turntype = TurnType.SnapTurn; } void EnableContinuousTurn() { SaveIntegerSettingsToPlayerPrefs(ConstantsManager.turnSettingPlayerPref, 1); + Debug.Log("Saved: " + 1); if (!locomotionsystem) return; snapTurn.enabled = false; continuousTurn.enabled = true; - } - - void TurnTypeSelected(int value) - { - switch (value) - { - case 1: - turntype = TurnType.ContinuousTurn; - break; - case 0: - default: - turntype = TurnType.SnapTurn; - break; - } + turntype = TurnType.ContinuousTurn; } void SaveIntegerSettingsToPlayerPrefs(string playerPrefEntry, int settingsValue) diff --git a/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs index 1ddc8018d..01fbd7bb6 100644 --- a/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs +++ b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs @@ -5,14 +5,8 @@ public class TurnSettingDropdownController_v2 : MonoBehaviour { - private RuntimeSettings runtimeSettings; - void Awake() { - - runtimeSettings.turntype = RuntimeSettings.TurnType.ContinuousTurn; - Debug.Log(runtimeSettings.turntype.ToString()); - var dropdown = transform.GetComponent(); dropdown.onValueChanged.AddListener(DropdownItemSelected); @@ -25,11 +19,11 @@ public void DropdownItemSelected(int value) switch (value) { case 1: - runtimeSettings.turntype = RuntimeSettings.TurnType.ContinuousTurn; + RuntimeSettings.I.DropdownItemSelected(RuntimeSettings.TurnType.ContinuousTurn); break; case 0: default: - runtimeSettings.turntype = RuntimeSettings.TurnType.SnapTurn; + RuntimeSettings.I.DropdownItemSelected(RuntimeSettings.TurnType.SnapTurn); break; } } From c392aca69bde5fb70165820009a3b53bd7616142 Mon Sep 17 00:00:00 2001 From: Romeeey <121696184+Romeeey@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:21:17 +0100 Subject: [PATCH 4/4] Reduced validate method to react only on changes --- ...meSettings.cs => PlayerSettingsManager.cs} | 24 +++++++++---------- ....cs.meta => PlayerSettingsManager.cs.meta} | 0 .../TurnSettingDropdownController_v2.cs | 6 ++--- 3 files changed, 15 insertions(+), 15 deletions(-) rename Assets/GothicVR/Scripts/Settings/{RuntimeSettings.cs => PlayerSettingsManager.cs} (77%) rename Assets/GothicVR/Scripts/Settings/{RuntimeSettings.cs.meta => PlayerSettingsManager.cs.meta} (100%) diff --git a/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs b/Assets/GothicVR/Scripts/Settings/PlayerSettingsManager.cs similarity index 77% rename from Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs rename to Assets/GothicVR/Scripts/Settings/PlayerSettingsManager.cs index 417f2551d..49b3ef01a 100644 --- a/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs +++ b/Assets/GothicVR/Scripts/Settings/PlayerSettingsManager.cs @@ -6,7 +6,7 @@ namespace GVR.Debugging { - public class RuntimeSettings : SingletonBehaviour + public class PlayerSettingsManager : SingletonBehaviour { public enum TurnType { @@ -23,14 +23,13 @@ public enum TurnType public GameObject locomotionsystem; public ActionBasedSnapTurnProvider snapTurn; public ActionBasedContinuousTurnProvider continuousTurn; + private bool isAwoken = false; - protected override void Awake() + protected void OnEnable() { - Debug.Log("Initial PlayerPref: " + PlayerPrefs.GetInt(ConstantsManager.turnSettingPlayerPref).ToString()); base.Awake(); + isAwoken = true; turntypeUI = (TurnType)PlayerPrefs.GetInt(ConstantsManager.turnSettingPlayerPref); - Debug.Log(PlayerPrefs.GetInt(ConstantsManager.turnSettingPlayerPref).ToString()); - Debug.Log(turntypeUI.ToString()); turntype = turntypeUI; DropdownItemSelected(turntypeUI); } @@ -38,22 +37,25 @@ protected override void Awake() #if UNITY_EDITOR void OnValidate() { - DropdownItemSelected(turntypeUI); + if (isAwoken) + { + DropdownItemSelected(turntypeUI); + } } #endif - public void DropdownItemSelected(TurnType turntypeUI) + public void DropdownItemSelected(TurnType selectedturntypeUI) { - switch(turntypeUI) + switch(selectedturntypeUI) { case TurnType.ContinuousTurn: EnableContinuousTurn(); - Debug.Log("Cont"); + turntypeUI = TurnType.ContinuousTurn; break; case TurnType.SnapTurn: default: EnableSnapTurn(); - Debug.Log("Snap"); + turntypeUI = TurnType.SnapTurn; break; } } @@ -61,7 +63,6 @@ public void DropdownItemSelected(TurnType turntypeUI) void EnableSnapTurn() { SaveIntegerSettingsToPlayerPrefs(ConstantsManager.turnSettingPlayerPref, 0); - Debug.Log("Saved: " + 0); if (!locomotionsystem) return; @@ -74,7 +75,6 @@ void EnableSnapTurn() void EnableContinuousTurn() { SaveIntegerSettingsToPlayerPrefs(ConstantsManager.turnSettingPlayerPref, 1); - Debug.Log("Saved: " + 1); if (!locomotionsystem) return; diff --git a/Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs.meta b/Assets/GothicVR/Scripts/Settings/PlayerSettingsManager.cs.meta similarity index 100% rename from Assets/GothicVR/Scripts/Settings/RuntimeSettings.cs.meta rename to Assets/GothicVR/Scripts/Settings/PlayerSettingsManager.cs.meta diff --git a/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs index 01fbd7bb6..4e81da0d4 100644 --- a/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs +++ b/Assets/GothicVR/Scripts/Settings/TurnSettingDropdownController_v2.cs @@ -10,7 +10,7 @@ void Awake() var dropdown = transform.GetComponent(); dropdown.onValueChanged.AddListener(DropdownItemSelected); - dropdown.value = RuntimeSettings.LoadSettingsFromPlayerPrefs(ConstantsManager.turnSettingPlayerPref); + dropdown.value = PlayerSettingsManager.LoadSettingsFromPlayerPrefs(ConstantsManager.turnSettingPlayerPref); DropdownItemSelected(dropdown.value); } @@ -19,11 +19,11 @@ public void DropdownItemSelected(int value) switch (value) { case 1: - RuntimeSettings.I.DropdownItemSelected(RuntimeSettings.TurnType.ContinuousTurn); + PlayerSettingsManager.I.DropdownItemSelected(PlayerSettingsManager.TurnType.ContinuousTurn); break; case 0: default: - RuntimeSettings.I.DropdownItemSelected(RuntimeSettings.TurnType.SnapTurn); + PlayerSettingsManager.I.DropdownItemSelected(PlayerSettingsManager.TurnType.SnapTurn); break; } }