Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        DrawPropertiesExcluding(serializedObject, new string[] { "_customBones" });
        serializedObject.ApplyModifiedProperties();

        OVRCustomSkeleton skeleton = (OVRCustomSkeleton)target;

        OVRSkeleton.SkeletonType skeletonType = skeleton.GetSkeletonType();

        if (skeletonType == OVRSkeleton.SkeletonType.None)
        {
            EditorGUILayout.HelpBox("Please select a SkeletonType.", MessageType.Warning);
        }
        else
        {
            if (GUILayout.Button("Auto Map Bones"))
            {
                skeleton.TryAutoMapBonesByName();
                EditorUtility.SetDirty(skeleton);
                EditorSceneManager.MarkSceneDirty(skeleton.gameObject.scene);
            }

            EditorGUILayout.LabelField("Bones", EditorStyles.boldLabel);
            BoneId start = skeleton.GetCurrentStartBoneId();
            BoneId end   = skeleton.GetCurrentEndBoneId();
            if (start != BoneId.Invalid && end != BoneId.Invalid)
            {
                for (int i = (int)start; i < (int)end; ++i)
                {
                    string boneName = BoneLabelFromBoneId(skeletonType, (BoneId)i);
                    skeleton.CustomBones[i] = (Transform)EditorGUILayout.ObjectField(boneName, skeleton.CustomBones[i], typeof(Transform), true);
                }
            }
        }
    }
Esempio n. 2
0
    public void SetupHands()
    {
        FindReferences();
        if (leftHand != null)
        {
            Debug.Log("Left hand is already setup and existing. GameObject name in scene: " + leftHand.name);
            Debug.Log("If you want to setup a new hand, delete the current hand in scene or push the 'Reset hands' button");
        }
        else if (leftHandPrefab != null)
        {
            leftHand      = Instantiate(leftHandPrefab, leftHandAnchor);
            leftHand.name = "Left Hand Prefab";
            leftHand.transform.localPosition = Vector3.zero;
            leftHand.AddComponent <OVRHand>().TestSetup(OVRHand.Hand.HandLeft);
            OVRCustomSkeleton skeleton = leftHand.AddComponent <OVRCustomSkeleton>();
            skeleton.TestSetup(OVRSkeleton.SkeletonType.HandLeft, true);
            skeleton.TryAutoMapBonesByName();
        }
        else
        {
            Debug.Log("Left prefab reference is not set yet. Skipping left hand setup");
        }

        if (rightHand != null)
        {
            Debug.Log("Right hand is already setup and existing. GameObject name in scene: " + rightHand.name);
            Debug.Log("If you want to setup a new hand, delete the current hand in scene or push the 'Reset hands' button");
        }
        else if (rightHandPrefab != null)
        {
            rightHand      = Instantiate(rightHandPrefab, rightHandAnchor);
            rightHand.name = "Right Hand Prefab";
            rightHand.transform.localPosition = Vector3.zero;
            rightHand.AddComponent <OVRHand>().TestSetup(OVRHand.Hand.HandRight);
            OVRCustomSkeleton skeleton = rightHand.AddComponent <OVRCustomSkeleton>();
            skeleton.TestSetup(OVRSkeleton.SkeletonType.HandRight, true);
            skeleton.TryAutoMapBonesByName();
        }
        else
        {
            Debug.Log("Right prefab reference is not set yet. Skipping right hand setup");
        }
        SetupHandsManager();
    }