Пример #1
0
        public static void OnConstraintListGUI(Constraint[] constraints, UnityEngine.Object context, GUISkin skin)
        {
            if (!GUI.Foldout(EditorData.Instance.GetData(context, "Constraints"), GUI.MakeLabel("Constraints", true), skin))
            {
                return;
            }

            if (constraints.Length == 0)
            {
                using (new GUI.Indent(12))
                    GUILayout.Label(GUI.MakeLabel("Empty", true), skin.label);
                return;
            }

            using (new GUI.Indent(12)) {
                foreach (var constraint in constraints)
                {
                    GUI.Separator();
                    if (!GUI.Foldout(EditorData.Instance.GetData(context, constraint.GetInstanceID().ToString()),
                                     GUI.MakeLabel("[" + GUI.AddColorTag(constraint.Type.ToString(), Color.Lerp(Color.magenta, Color.black, 0.4f)) + "] " + constraint.name),
                                     skin))
                    {
                        continue;
                    }

                    GUI.Separator();
                    var constraintTool = new ConstraintTool(constraint)
                    {
                        OnFoldoutStateChange = state => EditorUtility.SetDirty(context)
                    };
                    using (new GUI.Indent(12)) {
                        constraintTool.OnPreTargetMembersGUI(skin);
                    }
                }
            }
        }
Пример #2
0
        private void OnConstraintListGUI(GUISkin skin)
        {
            if (m_constraints.Count == 0)
            {
                return;
            }

            GUI.Separator();

            if (!GUI.Foldout(EditorData.Instance.GetData(RigidBody, "Constraints"), GUI.MakeLabel("Constraints", true), skin))
            {
                return;
            }

            using (new GUI.Indent(12)) {
                foreach (var constraint in m_constraints)
                {
                    GUI.Separator();
                    if (!GUI.Foldout(EditorData.Instance.GetData(RigidBody, constraint.GetInstanceID().ToString()),
                                     GUI.MakeLabel("[" + GUI.AddColorTag(constraint.Type.ToString(), Color.Lerp(Color.magenta, Color.black, 0.4f)) + "] " + constraint.name),
                                     skin))
                    {
                        continue;
                    }

                    GUI.Separator();
                    var constraintTool = new ConstraintTool(constraint)
                    {
                        OnFoldoutStateChange = state => EditorUtility.SetDirty(RigidBody)
                    };
                    using (new GUI.Indent(12)) {
                        constraintTool.OnPreTargetMembersGUI(skin);
                    }
                }
            }
        }