コード例 #1
0
 private void OnDestroy()
 {
     if (visibleHand)
     {
         GameObject.DestroyImmediate(visibleHand.gameObject);
     }
     currentHand  = HandtoEdit.none;
     Tools.hidden = false;
 }
コード例 #2
0
        private void OnDisable()
        {
            EditorApplication.update -= Update;

            if (visibleHand)
            {
                GameObject.DestroyImmediate(visibleHand.gameObject);
            }
            currentHand  = HandtoEdit.none;
            Tools.hidden = false;
        }
コード例 #3
0
        private void HandPositionSceneEditor(HandtoEdit hand)
        {
            if (visibleHand == null)
            {
                switch (hand)
                {
                case HandtoEdit.none:
                    break;

                case HandtoEdit.right:
                    visibleHand = GameObject.Instantiate <HandAnimationController>(interactable.handData.rightHandPrefab);
                    break;

                case HandtoEdit.left:
                    visibleHand = GameObject.Instantiate <HandAnimationController>(interactable.handData.leftHandPrefab);
                    break;

                default:
                    break;
                }
            }
            visibleHand.transform.parent = interactable.transform;

            switch (hand)
            {
            case HandtoEdit.none:
                break;

            case HandtoEdit.right:
                visibleHand.transform.localPosition = interactable.rightHandPivot.position;
                visibleHand.transform.localRotation = Quaternion.Euler(interactable.rightHandPivot.rotation);

                break;

            case HandtoEdit.left:
                visibleHand.transform.localPosition = interactable.leftHandPivot.position;
                visibleHand.transform.localRotation = Quaternion.Euler(interactable.leftHandPivot.rotation);
                break;

            default:
                break;
            }
        }
コード例 #4
0
        private void OnEnable()
        {
            Tools.hidden = false;

            interactable              = (Interactable)target;
            EditorApplication.update += Update;
            if (visibleHand)
            {
                GameObject.DestroyImmediate(visibleHand.gameObject);
                HandtoEdit currentHand = HandtoEdit.none;
            }
            else if (visibleHand = interactable.GetComponentInChildren <HandAnimationController>())
            {
                GameObject.DestroyImmediate(visibleHand.gameObject);
                visibleHand = null;
            }

            if (!interactable.handData)
            {
                interactable.handData = GameObject.FindObjectOfType <HandAnimationController>().HandData;
            }
        }
コード例 #5
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            if (Application.isPlaying)
            {
                if (visibleHand)
                {
                    DestroyImmediate(visibleHand);
                }
            }
            else if (interactable.handData)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Edit Right hand"))
                {
                    if (currentHand == HandtoEdit.right)
                    {
                        currentHand = HandtoEdit.none;
                    }
                    else
                    {
                        if (visibleHand)
                        {
                            DestroyImmediate(visibleHand.gameObject);
                        }
                        currentHand = HandtoEdit.right;
                    }
                }
                if (GUILayout.Button("Edit Left hand"))
                {
                    if (currentHand == HandtoEdit.left)
                    {
                        currentHand = HandtoEdit.none;
                    }
                    else
                    {
                        if (visibleHand)
                        {
                            DestroyImmediate(visibleHand.gameObject);
                        }

                        currentHand = HandtoEdit.left;
                    }
                }
                EditorGUILayout.EndHorizontal();
                if (currentHand != HandtoEdit.none)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.BeginVertical("GroupBox");
                    switch (currentHand)
                    {
                    case HandtoEdit.none:
                        break;

                    case HandtoEdit.right:
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("rightHandLimits"));
                        EditorGUILayout.Space();
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("rightHandPivot").FindPropertyRelative("position"));
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("rightHandPivot").FindPropertyRelative("rotation"));
                        break;

                    case HandtoEdit.left:
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("leftHandLimits"));
                        EditorGUILayout.Space();

                        EditorGUILayout.PropertyField(serializedObject.FindProperty("leftHandPivot").FindPropertyRelative("position"));
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("leftHandPivot").FindPropertyRelative("rotation"));
                        break;

                    default:
                        break;
                    }
                    EditorGUILayout.EndVertical();
                    EditorGUI.indentLevel--;
                    HandPositionSceneEditor(currentHand);
                }
                else
                {
                    if (visibleHand)
                    {
                        GameObject.DestroyImmediate(visibleHand.gameObject);
                    }
                }
                serializedObject.ApplyModifiedProperties();
            }
        }