diff --git a/TABGVR/Player/VRControls.cs b/TABGVR/Player/VRControls.cs index 67bf788..620e5de 100644 --- a/TABGVR/Player/VRControls.cs +++ b/TABGVR/Player/VRControls.cs @@ -222,6 +222,7 @@ private void Update() private void SnapTurn(int direction) { + UIPorter.UISnapTurnBase?.transform.Rotate(Vector3.up, direction * 45);; Controllers.SnapTurnParent.transform.Rotate(Vector3.up, direction * 45); player.m_cameraMovement.transform.Rotate(Vector3.up, direction * 45); } diff --git a/TABGVR/Util/UIPorter.cs b/TABGVR/Util/UIPorter.cs index 332bd53..db58ac5 100644 --- a/TABGVR/Util/UIPorter.cs +++ b/TABGVR/Util/UIPorter.cs @@ -16,6 +16,8 @@ internal static class UIPorter { private static bool _eventSystemSetUp; + [CanBeNull] internal static GameObject UISnapTurnBase; + internal static GameObject UILeftHand; internal static GameObject UIRightHand; @@ -61,6 +63,12 @@ internal static bool InteractorVisuals internal static void SetupInteractors(XRNode node) { + if (!UISnapTurnBase) + { + UISnapTurnBase = new GameObject("TABGVR_UISnapTurnBase"); + UISnapTurnBase.transform.SetParent(Controllers.VRFloor.transform, false); + } + if (UILeftHand && node == XRNode.LeftHand) return; if (UIRightHand && node == XRNode.RightHand) return; @@ -79,6 +87,8 @@ internal static void SetupInteractors(XRNode node) default: throw new ArgumentOutOfRangeException(nameof(node), node, null); } + + interactionController.transform.SetParent(UISnapTurnBase.transform); var controller = interactionController.AddComponent(); var interactor = interactionController.AddComponent(); @@ -121,8 +131,6 @@ internal static void SetupInteractors(XRNode node) lineRenderer.material = new Material(Shader.Find("Sprites/Default")); controller.controllerNode = node; - - interactionController.transform.SetParent(Controllers.VRFloor.transform, false); // InteractorMover.Interactors.Add(interactor); } @@ -136,6 +144,8 @@ internal static void SetupEventSystem() eventSystem.AddComponent(); eventSystem.GetComponent().enabled = false; + + UISnapTurnBase = null; // remove UISnapTurnBase if there's already one _eventSystemSetUp = true; }