diff --git a/Assets/_PROJECT/Components/NewHandPresence/TutorialController.cs b/Assets/_PROJECT/Components/NewHandPresence/TutorialController.cs index c9e03114..1ce88aa9 100644 --- a/Assets/_PROJECT/Components/NewHandPresence/TutorialController.cs +++ b/Assets/_PROJECT/Components/NewHandPresence/TutorialController.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; @@ -44,6 +45,26 @@ namespace _PROJECT.NewHandPresence private GameObject _billboard; + public enum TutorialInfoKey + { + Initialized, + LeftHintController, + RightHintController, + LeftSmartHandPresence, + RightSmartHandPresence + } + protected Dictionary initializationInfoStatus = new Dictionary(); + protected Coroutine initializationInfoCoroutine; + + private void Awake() + { + initializationInfoStatus.Add(TutorialInfoKey.Initialized, false); + initializationInfoStatus.Add(TutorialInfoKey.LeftHintController, false); + initializationInfoStatus.Add(TutorialInfoKey.RightHintController, false); + initializationInfoStatus.Add(TutorialInfoKey.LeftSmartHandPresence, false); + initializationInfoStatus.Add(TutorialInfoKey.RightSmartHandPresence, false); + } + private void Update() { if (_state == TutorialState.Initializing) @@ -177,29 +198,33 @@ namespace _PROJECT.NewHandPresence private void TryInitialize() { if (!CanInitialize()) return; + if (null == initializationInfoCoroutine) + { + initializationInfoCoroutine = StartCoroutine(InitializationInfoCoroutine()); + } _camera = Camera.main; - Debug.Log("Initializing tutorial"); + //Debug.Log("Initializing tutorial"); _leftHintController = leftHand.GetComponentInChildren(); _rightHintController = rightHand.GetComponentInChildren(); - Debug.Log($"Left hint controller: {_leftHintController}"); - Debug.Log($"Right hint controller: {_rightHintController}"); + initializationInfoStatus[TutorialInfoKey.LeftHintController] = null != _leftHintController; + initializationInfoStatus[TutorialInfoKey.RightHintController] = null != _rightHintController; _leftSmartHandPresence = leftHand.GetComponentInChildren(); _rightSmartHandPresence = rightHand.GetComponentInChildren(); - Debug.Log($"Left smart hand presence: {_leftSmartHandPresence}"); - Debug.Log($"Right smart hand presence: {_rightSmartHandPresence}"); + initializationInfoStatus[TutorialInfoKey.LeftSmartHandPresence] = null != _leftSmartHandPresence; + initializationInfoStatus[TutorialInfoKey.RightSmartHandPresence] = null != _rightSmartHandPresence; if (_leftHintController == null || _rightHintController == null || _leftSmartHandPresence == null || _rightSmartHandPresence == null) { - Debug.Log("Hint controller or smart hand presence is null"); + //Debug.Log("Hint controller or smart hand presence is null"); return; } @@ -216,6 +241,7 @@ namespace _PROJECT.NewHandPresence UpdateState(_state.Next()); Debug.Log("Tutorial initialized"); + StopCoroutine(initializationInfoCoroutine); } private void OnGripPerformed(SelectEnterEventArgs arg0) @@ -307,5 +333,35 @@ namespace _PROJECT.NewHandPresence } } + + + IEnumerator InitializationInfoCoroutine() + { + string CombineMessage(TutorialInfoKey key, object value, string prefix) + { + bool isAvailable = initializationInfoStatus.GetValueOrDefault(key); + + return prefix + ": " + (isAvailable ? value.ToString() : "NULL") + "\r\n"; + } + + bool isInitialized = initializationInfoStatus.GetValueOrDefault(TutorialInfoKey.Initialized); + while (!isInitialized) + { + isInitialized = initializationInfoStatus.GetValueOrDefault(TutorialInfoKey.Initialized); + + string infoMessage = "Tutorial not yet initialized!" + "\r\n"; + infoMessage += "(click me for more info)" + "\r\n"; + infoMessage += "Hint controllers" + "\r\n"; + infoMessage += CombineMessage(TutorialInfoKey.LeftHintController, _leftHintController, "Left"); + infoMessage += CombineMessage(TutorialInfoKey.RightHintController, _rightHintController, "Right"); + infoMessage += "Smart hand presence" + "\r\n"; + infoMessage += CombineMessage(TutorialInfoKey.LeftSmartHandPresence, _leftSmartHandPresence, "Left"); + infoMessage += CombineMessage(TutorialInfoKey.RightSmartHandPresence, _rightSmartHandPresence, "Right"); + Debug.Log(infoMessage); + + yield return new WaitForSeconds(7); + } + } + } } \ No newline at end of file