private void DestroyHand(HandModel hand_model)
{
if (destroyHands)
{
// Cleans up mirror hand object on deletion of its respective hand
if (hand_model.gameObject.name == "RigidHand(Clone)")
{
int handID = hand_model.GetLeapHand().Id;
GameObject refObj = GameObject.Find(handID.ToString());
// Detaches children to prevent deleting an object currently moving with the hand
GameObject cubes = GameObject.Find("Cubes");
if (refObj != null)
{
// refObj.transform.DetachChildren();
// if(refObj.transform.childCount > 0){
// refObj.transform.GetChild(0).parent = cubes.transform;
// }
for (int i = 0; i < cubes.transform.childCount; i++)
{
cubes.transform.GetChild(i).gameObject.renderer.material.color = Color.gray;
}
}
}
Destroy(hand_model.gameObject);
}
else
{
hand_model.SetLeapHand(null);
}
}