Пример #1
0
    private void OnGUI()
    {
        GUIStyle labelStyle = EditorStyles.label;

        labelStyle.alignment = TextAnchor.MiddleCenter;

        string poseName = activePose ? activePose.name : "No Pose";

        GUILayout.Label(poseName, labelStyle);

        using (new EditorGUI.DisabledScope(activePose))
        {
            if (GUILayout.Button("Create Pose"))
            {
                CreatePose();
            }

            if (GUILayout.Button("Refresh Pose"))
            {
                RefreshPose();
            }
        }

        using (new EditorGUI.DisabledScope(!activePose))
        {
            if (GUILayout.Button("Clear Pose"))
            {
                ClearPose();
            }
        }

        using (new EditorGUI.DisabledScope(!handManager.HandsExist))
        {
            PreviewHand leftHand    = handManager.LeftHand;
            PreviewHand rightHand   = handManager.RightHand;
            float       objectWidth = EditorGUIUtility.currentViewWidth * 0.5f;

            // Hand labels
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Left Hand", labelStyle, GUILayout.Width(objectWidth));
                GUILayout.Label("Right Hand", labelStyle, GUILayout.Width(objectWidth));
            }

            // Toggle buttons
            using (new GUILayout.HorizontalScope())
            {
                if (GUILayout.Button("Toggle", GUILayout.Width(objectWidth)))
                {
                    ToggleHand(leftHand);
                }

                if (GUILayout.Button("Toggle", GUILayout.Width(objectWidth)))
                {
                    ToggleHand(rightHand);
                }
            }

            // Buttons that require a pose
            using (new EditorGUI.DisabledScope(!activePose))
            {
                using (new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Mirror L > R", GUILayout.Width(objectWidth)))
                    {
                        MirrorPose(leftHand, rightHand);
                    }

                    if (GUILayout.Button("Mirror R > L", GUILayout.Width(objectWidth)))
                    {
                        MirrorPose(rightHand, leftHand);
                    }
                }

                using (new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Undo Changes", GUILayout.Width(objectWidth)))
                    {
                        UndoChanges(leftHand);
                    }

                    if (GUILayout.Button("Undo Changes", GUILayout.Width(objectWidth)))
                    {
                        UndoChanges(rightHand);
                    }
                }

                using (new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Reset", GUILayout.Width(objectWidth)))
                    {
                        ResetPose(leftHand);
                    }

                    if (GUILayout.Button("Reset", GUILayout.Width(objectWidth)))
                    {
                        ResetPose(rightHand);
                    }
                }
            }
        }

        using (new EditorGUI.DisabledScope(!activePose))
        {
            GUILayout.Label("Remember to Save!", labelStyle);

            if (GUILayout.Button("Save Pose"))
            {
                handManager.SavePose(activePose);
            }
        }
    }