コード例 #1
0
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            var  disabledPairs = Manager.DisabledPairs;
            bool clearPressed  = false;
            bool addPressed    = false;
            CollisionGroupEntryPair erasePair = null;

            GUILayout.Label(GUI.MakeLabel("Collision Groups Manager", 18, true), new GUIStyle(skin.label)
            {
                alignment = TextAnchor.MiddleCenter
            });

            GUI.Separator3D();

            GUILayout.Label(GUI.MakeLabel("Add pair", true), new GUIStyle(skin.label)
            {
                alignment = TextAnchor.MiddleCenter
            });

            GUILayout.BeginVertical(skin.textArea);
            {
                HandleCollisionGroupEntryPair(m_groupEntryPairToAdd, skin);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();

                    UnityEngine.GUI.enabled = m_groupEntryPairToAdd.First.Tag.Length > 0 || m_groupEntryPairToAdd.Second.Tag.Length > 0;
                    GUILayout.BeginVertical();
                    {
                        GUILayout.Space(8);
                        using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.red, 0.1f)))
                            clearPressed = GUILayout.Button(GUI.MakeLabel("Clear"), skin.button, GUILayout.Width(64), GUILayout.Height(16));
                    }
                    GUILayout.EndVertical();

                    UnityEngine.GUI.enabled = m_groupEntryPairToAdd.First.Tag.Length > 0 && m_groupEntryPairToAdd.Second.Tag.Length > 0;
                    using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.green, 0.1f)))
                        addPressed = GUILayout.Button(GUI.MakeLabel("Add", false, "Add pair to disabled pairs."), skin.button, GUILayout.Width(64), GUILayout.Height(22));

                    UnityEngine.GUI.enabled = true;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            GUI.Separator3D();

            if (GUI.Foldout(FoldoutDataEntry, GUI.MakeLabel("Disabled Pairs [" + disabledPairs.Length + "]"), skin))
            {
                using (new GUI.Indent(12)) {
                    foreach (var disabledPair in disabledPairs)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUI.Separator(1, 10);
                            using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.red, 0.1f)))
                                if (GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListEraseElement.ToString()), skin.button, GUILayout.Width(18), GUILayout.Height(14)))
                                {
                                    erasePair = disabledPair;
                                }
                        }
                        GUILayout.EndHorizontal();

                        HandleCollisionGroupEntryPair(disabledPair, skin);
                    }
                }
            }

            GUI.Separator3D();

            if (clearPressed)
            {
                m_groupEntryPairToAdd.First.Tag = m_groupEntryPairToAdd.Second.Tag = string.Empty;
            }
            if (addPressed)
            {
                Manager.SetEnablePair(m_groupEntryPairToAdd.First.Tag, m_groupEntryPairToAdd.Second.Tag, false);
                m_groupEntryPairToAdd.First.Tag = m_groupEntryPairToAdd.Second.Tag = string.Empty;
                FoldoutDataEntry.Bool           = true;
            }
            if (erasePair != null)
            {
                if (EditorUtility.DisplayDialog("Remove pair", "Erase disabled pair: " + erasePair.First.Tag + " and " + erasePair.Second.Tag + "?", "Yes", "No"))
                {
                    Manager.SetEnablePair(erasePair.First.Tag, erasePair.Second.Tag, true);
                }
            }
        }
コード例 #2
0
        public override void OnPreTargetMembersGUI()
        {
            var  skin          = InspectorEditor.Skin;
            var  disabledPairs = Manager.DisabledPairs;
            bool clearPressed  = false;
            bool addPressed    = false;
            CollisionGroupEntryPair erasePair = null;

            GUILayout.Label(GUI.MakeLabel("Add pair",
                                          true),
                            skin.LabelMiddleCenter);

            GUILayout.BeginVertical(skin.TextArea);
            {
                HandleCollisionGroupEntryPair(m_groupEntryPairToAdd);

                var buttonState = InspectorGUI.PositiveNegativeButtons(m_groupEntryPairToAdd.First.Tag.Length > 0 ||
                                                                       m_groupEntryPairToAdd.Second.Tag.Length > 0,
                                                                       "Add",
                                                                       "Add pair to disabled pairs.",
                                                                       "Clear");
                addPressed   = buttonState == InspectorGUI.PositiveNegativeResult.Positive;
                clearPressed = buttonState == InspectorGUI.PositiveNegativeResult.Negative;
            }
            GUILayout.EndVertical();

            if (InspectorGUI.Foldout(FoldoutDataEntry, GUI.MakeLabel("Disabled Pairs [" + disabledPairs.Length + "]")))
            {
                using (InspectorGUI.IndentScope.Single) {
                    foreach (var disabledPair in disabledPairs)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            InspectorGUI.Separator(1, EditorGUIUtility.singleLineHeight);

                            if (InspectorGUI.Button(MiscIcon.EntryRemove,
                                                    true,
                                                    "Remove pair from list.",
                                                    GUILayout.Width(18)))
                            {
                                erasePair = disabledPair;
                            }
                        }
                        GUILayout.EndHorizontal();

                        HandleCollisionGroupEntryPair(disabledPair);

                        // TODO GUI: Maybe unnecessary space with correct separator.
                        GUILayout.Space(6.0f);
                    }
                }
            }

            if (clearPressed)
            {
                m_groupEntryPairToAdd.First.Tag = m_groupEntryPairToAdd.Second.Tag = string.Empty;
            }
            if (addPressed)
            {
                Manager.SetEnablePair(m_groupEntryPairToAdd.First.Tag, m_groupEntryPairToAdd.Second.Tag, false);
                m_groupEntryPairToAdd.First.Tag = m_groupEntryPairToAdd.Second.Tag = string.Empty;
                FoldoutDataEntry.Bool           = true;
            }
            if (erasePair != null)
            {
                if (EditorUtility.DisplayDialog("Remove pair",
                                                "Erase disabled pair: " + erasePair.First.Tag + " and " + erasePair.Second.Tag + "?",
                                                "Yes",
                                                "No"))
                {
                    Manager.SetEnablePair(erasePair.First.Tag, erasePair.Second.Tag, true);
                }
            }
        }