Reworked the TutorialController so that it will show the info about trying to initialize once per some time interval. Not flood the entire log.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
@@ -44,6 +45,26 @@ namespace _PROJECT.NewHandPresence
|
|||||||
|
|
||||||
private GameObject _billboard;
|
private GameObject _billboard;
|
||||||
|
|
||||||
|
public enum TutorialInfoKey
|
||||||
|
{
|
||||||
|
Initialized,
|
||||||
|
LeftHintController,
|
||||||
|
RightHintController,
|
||||||
|
LeftSmartHandPresence,
|
||||||
|
RightSmartHandPresence
|
||||||
|
}
|
||||||
|
protected Dictionary<TutorialInfoKey, bool> initializationInfoStatus = new Dictionary<TutorialInfoKey, bool>();
|
||||||
|
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()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (_state == TutorialState.Initializing)
|
if (_state == TutorialState.Initializing)
|
||||||
@@ -177,29 +198,33 @@ namespace _PROJECT.NewHandPresence
|
|||||||
private void TryInitialize()
|
private void TryInitialize()
|
||||||
{
|
{
|
||||||
if (!CanInitialize()) return;
|
if (!CanInitialize()) return;
|
||||||
|
if (null == initializationInfoCoroutine)
|
||||||
|
{
|
||||||
|
initializationInfoCoroutine = StartCoroutine(InitializationInfoCoroutine());
|
||||||
|
}
|
||||||
|
|
||||||
_camera = Camera.main;
|
_camera = Camera.main;
|
||||||
|
|
||||||
Debug.Log("Initializing tutorial");
|
//Debug.Log("Initializing tutorial");
|
||||||
|
|
||||||
_leftHintController = leftHand.GetComponentInChildren<XRControllerHintController>();
|
_leftHintController = leftHand.GetComponentInChildren<XRControllerHintController>();
|
||||||
_rightHintController = rightHand.GetComponentInChildren<XRControllerHintController>();
|
_rightHintController = rightHand.GetComponentInChildren<XRControllerHintController>();
|
||||||
|
|
||||||
Debug.Log($"Left hint controller: {_leftHintController}");
|
initializationInfoStatus[TutorialInfoKey.LeftHintController] = null != _leftHintController;
|
||||||
Debug.Log($"Right hint controller: {_rightHintController}");
|
initializationInfoStatus[TutorialInfoKey.RightHintController] = null != _rightHintController;
|
||||||
|
|
||||||
_leftSmartHandPresence = leftHand.GetComponentInChildren<SmartHandPresence>();
|
_leftSmartHandPresence = leftHand.GetComponentInChildren<SmartHandPresence>();
|
||||||
_rightSmartHandPresence = rightHand.GetComponentInChildren<SmartHandPresence>();
|
_rightSmartHandPresence = rightHand.GetComponentInChildren<SmartHandPresence>();
|
||||||
|
|
||||||
Debug.Log($"Left smart hand presence: {_leftSmartHandPresence}");
|
initializationInfoStatus[TutorialInfoKey.LeftSmartHandPresence] = null != _leftSmartHandPresence;
|
||||||
Debug.Log($"Right smart hand presence: {_rightSmartHandPresence}");
|
initializationInfoStatus[TutorialInfoKey.RightSmartHandPresence] = null != _rightSmartHandPresence;
|
||||||
|
|
||||||
if (_leftHintController == null ||
|
if (_leftHintController == null ||
|
||||||
_rightHintController == null ||
|
_rightHintController == null ||
|
||||||
_leftSmartHandPresence == null ||
|
_leftSmartHandPresence == null ||
|
||||||
_rightSmartHandPresence == null)
|
_rightSmartHandPresence == null)
|
||||||
{
|
{
|
||||||
Debug.Log("Hint controller or smart hand presence is null");
|
//Debug.Log("Hint controller or smart hand presence is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,6 +241,7 @@ namespace _PROJECT.NewHandPresence
|
|||||||
|
|
||||||
UpdateState(_state.Next());
|
UpdateState(_state.Next());
|
||||||
Debug.Log("Tutorial initialized");
|
Debug.Log("Tutorial initialized");
|
||||||
|
StopCoroutine(initializationInfoCoroutine);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGripPerformed(SelectEnterEventArgs arg0)
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user