Create a gist now

Instantly share code, notes, and snippets.

@kihira /HandInfoPanel.cs Secret
Last active Apr 2, 2016

What would you like to do?
[Header("Tracking Settings")]
[SerializeField] private HandController handController;
[SerializeField] private float retrackTime = 2f;
private float detachedTime = 0f;
[Header("UI")]
[SerializeField] private GameObject canvas;
private HandModel hand;
void Update()
{
// Attempt to reattach if possible
if (hand == null)
{
if (detachedTime > retrackTime && canvas.activeSelf)
{
Debug.Log("Failed to retrack correct hand, deactivating canvas");
canvas.SetActive(false);
return;
}
foreach (var graphicHand in handController.GetAllGraphicsHands())
{
if (!graphicHand.GetLeapHand().IsLeft)
{
hand = graphicHand;
detachedTime = 0f;
break;
}
}
detachedTime += Time.deltaTime;
}
if (hand == null) return;
UpdatePosition();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment