Beispiel #1
0
        public static Constraint.ECollisionsState ConstraintCollisionsStateGUI(Constraint.ECollisionsState state, GUISkin skin)
        {
            bool guiWasEnabled = UnityEngine.GUI.enabled;

            using (new GUI.Indent(12)) {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(GUI.MakeLabel("Disable collisions: ", true), GUI.Align(skin.label, TextAnchor.MiddleLeft), new GUILayoutOption[] { GUILayout.Width(140), GUILayout.Height(25) });

                    UnityEngine.GUI.enabled = !EditorApplication.isPlaying;
                    if (GUILayout.Button(GUI.MakeLabel("Rb " + GUI.Symbols.Synchronized.ToString() + " Rb", false, "Disable all shapes in rigid body 1 against all shapes in rigid body 2."),
                                         GUI.ConditionalCreateSelectedStyle(state == Constraint.ECollisionsState.DisableRigidBody1VsRigidBody2, skin.button),
                                         new GUILayoutOption[] { GUILayout.Width(76), GUILayout.Height(25) }))
                    {
                        state = state == Constraint.ECollisionsState.DisableRigidBody1VsRigidBody2 ?
                                Constraint.ECollisionsState.KeepExternalState :
                                Constraint.ECollisionsState.DisableRigidBody1VsRigidBody2;
                    }

                    if (GUILayout.Button(GUI.MakeLabel("Ref " + GUI.Symbols.Synchronized.ToString() + " Con", false, "Disable Reference object vs. Connected object."),
                                         GUI.ConditionalCreateSelectedStyle(state == Constraint.ECollisionsState.DisableReferenceVsConnected, skin.button),
                                         new GUILayoutOption[] { GUILayout.Width(76), GUILayout.Height(25) }))
                    {
                        state = state == Constraint.ECollisionsState.DisableReferenceVsConnected ?
                                Constraint.ECollisionsState.KeepExternalState :
                                Constraint.ECollisionsState.DisableReferenceVsConnected;
                    }
                    UnityEngine.GUI.enabled = guiWasEnabled;
                }
                GUILayout.EndHorizontal();
            }

            return(state);
        }
Beispiel #2
0
        public static Constraint.ECollisionsState ConstraintCollisionsStateGUI(Constraint.ECollisionsState state)
        {
            var skin          = InspectorEditor.Skin;
            var guiWasEnabled = UnityEngine.GUI.enabled;

            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel(GUI.MakeLabel("Disable Collisions", true),
                                            InspectorEditor.Skin.LabelMiddleLeft);

                UnityEngine.GUI.enabled = !EditorApplication.isPlaying;
                var rbVsRbActive = !EditorGUI.showMixedValue &&
                                   state == Constraint.ECollisionsState.DisableRigidBody1VsRigidBody2;
                var refVsConActive = !EditorGUI.showMixedValue &&
                                     state == Constraint.ECollisionsState.DisableReferenceVsConnected;

                if (GUILayout.Button(GUI.MakeLabel("Rb " + GUI.Symbols.ArrowLeftRight.ToString() + " Rb",
                                                   rbVsRbActive,
                                                   "Disable all shapes in rigid body 1 against all shapes in rigid body 2."),
                                     skin.GetButton(rbVsRbActive,
                                                    InspectorGUISkin.ButtonType.Left),
                                     GUILayout.Width(76)))
                {
                    state = state == Constraint.ECollisionsState.DisableRigidBody1VsRigidBody2 ?
                            Constraint.ECollisionsState.KeepExternalState :
                            Constraint.ECollisionsState.DisableRigidBody1VsRigidBody2;
                }

                if (GUILayout.Button(GUI.MakeLabel("Ref " + GUI.Symbols.ArrowLeftRight.ToString() + " Con",
                                                   refVsConActive,
                                                   "Disable Reference object vs. Connected object."),
                                     skin.GetButton(refVsConActive,
                                                    InspectorGUISkin.ButtonType.Right),
                                     GUILayout.Width(76)))
                {
                    state = state == Constraint.ECollisionsState.DisableReferenceVsConnected ?
                            Constraint.ECollisionsState.KeepExternalState :
                            Constraint.ECollisionsState.DisableReferenceVsConnected;
                }
                UnityEngine.GUI.enabled = guiWasEnabled;
            }
            GUILayout.EndHorizontal();

            return(state);
        }