Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
54 changes: 34 additions & 20 deletions Assets/GothicVR/Scenes/General.unity
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ 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: 2133138095488065320, guid: 4600f492db92202478d7c53019a519d0, type: 3}
propertyPath: settingsManager
value:
objectReference: {fileID: 1353668846}
- target: {fileID: 3286136461781483594, guid: 4600f492db92202478d7c53019a519d0, type: 3}
propertyPath: m_Name
value: VRPlayer
Expand Down Expand Up @@ -184,41 +184,38 @@ 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: []
m_AddedComponents: []
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
Expand All @@ -228,6 +225,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1353668847}
- component: {fileID: 1353668848}
m_Layer: 0
m_Name: PlayerController
m_TagString: Untagged
Expand All @@ -251,6 +249,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:
turntypeUI: 0
locomotionsystem: {fileID: 1263267814}
snapTurn: {fileID: 1263267813}
continuousTurn: {fileID: 1263267811}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
Expand Down
8 changes: 8 additions & 0 deletions Assets/GothicVR/Scripts/Settings.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 99 additions & 0 deletions Assets/GothicVR/Scripts/Settings/PlayerSettingsManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using GVR.Util;
using UnityEngine;
using GVR.Manager;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.SceneManagement;

namespace GVR.Debugging
{
public class PlayerSettingsManager : SingletonBehaviour<PlayerSettingsManager>
{
public enum TurnType
{
SnapTurn,
ContinuousTurn
};

[Header("__________Movement__________")]
[Tooltip("Movement settings")]

public static TurnType turntype;
public TurnType turntypeUI;

public GameObject locomotionsystem;
public ActionBasedSnapTurnProvider snapTurn;
public ActionBasedContinuousTurnProvider continuousTurn;
private bool isAwoken = false;

protected void OnEnable()
{
base.Awake();
isAwoken = true;
turntypeUI = (TurnType)PlayerPrefs.GetInt(ConstantsManager.turnSettingPlayerPref);
turntype = turntypeUI;
DropdownItemSelected(turntypeUI);
}

#if UNITY_EDITOR
void OnValidate()
{
if (isAwoken)
{
DropdownItemSelected(turntypeUI);
}
}
#endif

public void DropdownItemSelected(TurnType selectedturntypeUI)
{
switch(selectedturntypeUI)
{
case TurnType.ContinuousTurn:
EnableContinuousTurn();
turntypeUI = TurnType.ContinuousTurn;
break;
case TurnType.SnapTurn:
default:
EnableSnapTurn();
turntypeUI = TurnType.SnapTurn;
break;
}
}

void EnableSnapTurn()
{
SaveIntegerSettingsToPlayerPrefs(ConstantsManager.turnSettingPlayerPref, 0);

if (!locomotionsystem)
return;

snapTurn.enabled = true;
continuousTurn.enabled = false;
turntype = TurnType.SnapTurn;
}

void EnableContinuousTurn()
{
SaveIntegerSettingsToPlayerPrefs(ConstantsManager.turnSettingPlayerPref, 1);

if (!locomotionsystem)
return;

snapTurn.enabled = false;
continuousTurn.enabled = true;
turntype = TurnType.ContinuousTurn;
}

void SaveIntegerSettingsToPlayerPrefs(string playerPrefEntry, int settingsValue)
{
PlayerPrefs.SetInt(playerPrefEntry, settingsValue);
}

public static int LoadSettingsFromPlayerPrefs(string playerPrefEntry)
{
int playerPrefValue = PlayerPrefs.GetInt(playerPrefEntry);
return playerPrefValue;
}

}
}
11 changes: 11 additions & 0 deletions Assets/GothicVR/Scripts/Settings/PlayerSettingsManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using TMPro;
using UnityEngine;
using GVR.Debugging;
using GVR.Manager;

public class TurnSettingDropdownController_v2 : MonoBehaviour
{
void Awake()
{
var dropdown = transform.GetComponent<TMP_Dropdown>();
dropdown.onValueChanged.AddListener(DropdownItemSelected);

dropdown.value = PlayerSettingsManager.LoadSettingsFromPlayerPrefs(ConstantsManager.turnSettingPlayerPref);
DropdownItemSelected(dropdown.value);
}

public void DropdownItemSelected(int value)
{
switch (value)
{
case 1:
PlayerSettingsManager.I.DropdownItemSelected(PlayerSettingsManager.TurnType.ContinuousTurn);
break;
case 0:
default:
PlayerSettingsManager.I.DropdownItemSelected(PlayerSettingsManager.TurnType.SnapTurn);
break;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.