Пример #1
0
    public void InitVirtualJoints(string name, List <GameObject> joints)
    {
        if (m_jointSkeletonParent == null)
        {
            m_jointSkeletonParent = new GameObject(name);   // An empty game object
        }
        foreach (GameObject joint in joints)
        {
            GameObject virtualJoint = Instantiate(m_jointPrefab, joint.transform.position, joint.transform.rotation,
                                                  m_jointSkeletonParent.transform);
            VirtualJointController controller = virtualJoint.AddComponent <VirtualJointController>();

            m_jointMap.Add(virtualJoint, joint);

            GameObject virtualSkeleton = Instantiate(m_skeletonPrefab, m_jointSkeletonParent.transform);

            controller.Initialize(joint, joint == m_root ? null : joint.transform.parent.gameObject, virtualSkeleton);
        }

        // Draw skeletons or not
        if (m_drawSkeleton)
        {
            DrawJointsAndSkeletons();
        }
        else
        {
            SetDrawSkeletons(false);
        }
    }
Пример #2
0
 public void InitializeTargetJoints(GameObject[] endJoints)
 {
     if (m_targetJointParent == null)
     {
         m_targetJointParent = new GameObject("Target");   // An empty game object
     }
     foreach (GameObject endJoint in endJoints)
     {
         GameObject targetJoint = Instantiate(m_targetPrefab, endJoint.transform.position, endJoint.transform.rotation,
                                              m_targetJointParent.transform);
         VirtualJointController controller = targetJoint.AddComponent <VirtualJointController>();
         controller.Initialize(endJoint, null, null);
         m_targetJoints.Add(targetJoint);
     }
     // Do not draw targets at first
     SetDrawTargets(false);
 }