private void OnGUI()
        {
            SpringBoneGUIStyles.ReacquireStyles();

            const int ButtonHeight = 30;
            const int UISpacing    = 8;
            const int UIRowHeight  = 24;

            var uiWidth = (int)position.width - UISpacing * 2;
            var yPos    = UISpacing;

            springBoneRoot = LoadSpringBoneSetupWindow.DoObjectPicker(
                "スプリングボーンのルート", springBoneRoot, uiWidth, UIRowHeight, ref yPos);
            var buttonRect = new Rect(UISpacing, yPos, uiWidth, ButtonHeight);

            if (GUI.Button(buttonRect, "選択からルートを取得", SpringBoneGUIStyles.ButtonStyle))
            {
                SelectObjectsFromSelection();
            }
            yPos        += ButtonHeight + UISpacing;
            buttonRect.y = yPos;

            ShowExportSettingsUI(ref buttonRect);
            if (springBoneRoot != null)
            {
                if (GUI.Button(buttonRect, "CSVを保存", SpringBoneGUIStyles.ButtonStyle))
                {
                    BrowseAndSaveSpringSetup();
                }
            }
        }
Example #2
0
        public void ShowInspector()
        {
            if (totalBoneCount == 0)
            {
                return;
            }

            const string SelectAllLabel = "全選択";

            SpringBoneGUIStyles.ReacquireStyles();

            EditorGUILayout.Space();
            GUILayout.BeginVertical("box");
            GUILayout.Label(springBoneTitle, SpringBoneGUIStyles.HeaderLabelStyle);
            EditorGUILayout.Space();

            var groupCount = affectedBoneGroups.Length;

            if (groupCount >= 2)
            {
                if (GUILayout.Button(SelectAllLabel, SpringBoneGUIStyles.ButtonStyle))
                {
                    Selection.objects = affectedBoneGroups
                                        .SelectMany(group => group.bones)
                                        .Select(bone => bone.gameObject)
                                        .ToArray();
                }
                EditorGUILayout.Space();
            }

            for (int groupIndex = 0; groupIndex < groupCount; groupIndex++)
            {
                var bones     = affectedBoneGroups[groupIndex].bones;
                var boneCount = bones.Length;

                GUILayout.BeginVertical("box");
                EditorGUILayout.Space();
                EditorGUILayout.ObjectField("Manager", affectedBoneGroups[groupIndex].manager, typeof(SpringManager), true);
                GUILayout.Label(affectedBoneGroups[groupIndex].boneCountLabel);
                if (boneCount >= 2 && GUILayout.Button(SelectAllLabel))
                {
                    Selection.objects = bones.Select(bone => bone.gameObject).ToArray();
                }
                EditorGUILayout.Space();

                for (int boneIndex = 0; boneIndex < boneCount; boneIndex++)
                {
                    EditorGUILayout.ObjectField(bones[boneIndex], typeof(SpringBone), true);
                }
                EditorGUILayout.Space();
                GUILayout.EndVertical();
                EditorGUILayout.Space();
            }
            GUILayout.EndVertical();
            EditorGUILayout.Space();
        }
        private void OnGUI()
        {
            SpringBoneGUIStyles.ReacquireStyles();

            if (boneEntries == null)
            {
                AcquireBonesFromSelection();
            }

            var uiRect = new Rect(Spacing, Spacing, position.width - Spacing * 2f, RowHeight);

            uiRect = ShowUtilityButtons(uiRect);
            uiRect = ShowBoneList(uiRect);
            if (GUI.Button(uiRect, "执行镜像", SpringBoneGUIStyles.ButtonStyle))
            {
                PerformMirror();
            }
        }
        private void OnGUI()
        {
            SpringBoneGUIStyles.ReacquireStyles();

            const int ButtonHeight = 30;

            var uiWidth = (int)position.width - UISpacing * 2;
            var yPos    = UISpacing;

            springBoneRoot = DoObjectPicker("SpringBone的根节点", springBoneRoot, uiWidth, UIRowHeight, ref yPos);
            var buttonRect = new Rect(UISpacing, yPos, uiWidth, ButtonHeight);

            if (GUI.Button(buttonRect, "选择当前所选物体", SpringBoneGUIStyles.ButtonStyle))
            {
                SelectObjectsFromSelection();
            }
            yPos        += ButtonHeight + UISpacing;
            buttonRect.y = yPos;

            ShowImportSettingsUI(ref buttonRect);

            string errorMessage;

            if (IsOkayToSetup(out errorMessage))
            {
                if (GUI.Button(buttonRect, "从CSV文件导入并设置", SpringBoneGUIStyles.ButtonStyle))
                {
                    BrowseAndLoadSpringSetup();
                }
            }
            else
            {
                const int MessageHeight = 24;
                var       uiRect        = new Rect(UISpacing, buttonRect.y, uiWidth, MessageHeight);
                GUI.Label(uiRect, errorMessage, SpringBoneGUIStyles.HeaderLabelStyle);
            }
        }
        private void OnGUI()
        {
            if (settings == null)
            {
                LoadSettings();
            }

            SpringBoneGUIStyles.ReacquireStyles();
            InitializeIcons();
            InitializeButtonGroups();

            var xPos = GUIElements.Spacing;
            var yPos = GUIElements.Spacing;
            var scrollContentsRect = GetScrollContentsRect();

            yPos = ShowHeaderUI(xPos, yPos, scrollContentsRect.width);
            var scrollViewRect = new Rect(0f, yPos, position.width, position.height - yPos);

            scrollPosition = GUI.BeginScrollView(scrollViewRect, scrollPosition, scrollContentsRect);
            mainUI.DoUI(GUIElements.Spacing, 0f, scrollContentsRect.width);
            GUI.EndScrollView();

            ApplySettings();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            SpringBoneGUIStyles.ReacquireStyles();

            var bone = (SpringBone)target;

            if (GUILayout.Button("Select Pivot Node", SpringBoneGUIStyles.ButtonStyle))
            {
                Selection.objects = targets
                                    .Select(item => ((SpringBone)item).pivotNode)
                                    .Where(pivotNode => pivotNode != null)
                                    .Select(pivotNode => pivotNode.gameObject)
                                    .ToArray();
            }

            GUILayout.BeginVertical("box");
            var managerCount = managers.Length;

            for (int managerIndex = 0; managerIndex < managerCount; managerIndex++)
            {
                EditorGUILayout.ObjectField("マネージャー", managers[managerIndex], typeof(SpringManager), true);
            }
            var newEnabled = EditorGUILayout.Toggle("有効", bone.enabled);

            GUILayout.EndVertical();

            if (newEnabled != bone.enabled)
            {
                var targetBones = serializedObject.targetObjects
                                  .Select(target => target as SpringBone)
                                  .Where(targetBone => targetBone != null);
                if (targetBones.Any())
                {
                    Undo.RecordObjects(targetBones.ToArray(), "SpringBoneの有効状態を変更");
                    foreach (var targetBone in targetBones)
                    {
                        targetBone.enabled = newEnabled;
                    }
                }
            }

            var setCount = propertySets.Length;

            for (int setIndex = 0; setIndex < setCount; setIndex++)
            {
                propertySets[setIndex].Show();
            }
            GUILayout.Space(Spacing);

            serializedObject.ApplyModifiedProperties();

            if (targets.Length == 1)
            {
                RenderAngleLimitVisualization();
            }

            showOriginalInspector = EditorGUILayout.Toggle("Show Original Inspector", showOriginalInspector);
            GUILayout.Space(Spacing);
            if (showOriginalInspector)
            {
                base.OnInspectorGUI();
            }
        }