public void DrawColliderActions()
        {
            const float BtnWidth = 60;

            EditorGUILayout.LabelField("Manage Colliders");

            var outfit = Target;

            LizEditorGUIUtil.BeginLabelWidth(50);

            EditorGUILayout.LabelField("Behavior");
            EditorGUILayout.BeginHorizontal();

            m_RigidbodyBehaviorChoice = (RigidbodyBehavior)EditorGUILayout.EnumPopup(m_RigidbodyBehaviorChoice);

            GUI.enabled = outfit.BodyPartCount > 0;
            if (GUILayout.Button(BodyPartStatusLabel, GUILayout.MaxWidth(BtnWidth)))
            {
                ApplyBodyPartColliderStatus(outfit, m_RigidbodyBehaviorChoice);
            }
            GUI.enabled = true;

            GUI.enabled = outfit.PrimaryRigidbody;
            if (GUILayout.Button(PrimaryStatusLabel, GUILayout.MaxWidth(BtnWidth)))
            {
                LizEditorGUIUtil.SetRigidbodyBehavior(outfit.PrimaryRigidbody, m_RigidbodyBehaviorChoice);
            }
            GUI.enabled = true;

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField("Layer");
            EditorGUILayout.BeginHorizontal();
            m_ColliderLayer = EditorGUILayout.LayerField(m_ColliderLayer);

            GUI.enabled = outfit.BodyPartCount > 0;
            if (GUILayout.Button(BodyPartStatusLabel, GUILayout.MaxWidth(BtnWidth)))
            {
                ApplyBodyPartLayer(outfit, m_ColliderLayer);
            }
            GUI.enabled = true;

            GUI.enabled = outfit.PrimaryCollider;
            if (GUILayout.Button(PrimaryStatusLabel, GUILayout.MaxWidth(BtnWidth)))
            {
                SetPrimaryColliderLayer(outfit, m_ColliderLayer);
            }
            GUI.enabled = true;

            EditorGUILayout.EndHorizontal();

            LizEditorGUIUtil.EndLabelWidth();
        }
        private void DrawActions()
        {
            var bp = Target;

            // Note: Rigidbody is guarenteed.

            var nstatus = LizEditorGUI.ColliderBehaviorPopup(
                EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight), m_StatusLabel,
                bp.ColliderBehavior, ColliderBehaviorCategory.RigidBody);

            if (nstatus != bp.ColliderBehavior)
            {
                var rb = bp.Rigidbody;
                if (rb)
                {
                    LizEditorGUIUtil.SetRigidbodyBehavior(rb, (RigidbodyBehavior)nstatus);
                }
            }
        }
Beispiel #3
0
        public static void ApplyBodyPartColliderStatus(Outfit outfit, RigidbodyBehavior status, bool singleUndo = true,
                                                       string undoLabel = "Set BP Collider Status")
        {
            if (AssetDatabase.Contains(outfit))
            {
                Debug.LogError("Can't modify an outfit asset.  Outfit must be in the scene.", outfit);
                return;
            }

            if (outfit.BodyPartCount == 0)
            {
                return;
            }

            if (singleUndo)
            {
                Undo.IncrementCurrentGroup();
            }

            for (int i = 0; i < outfit.BodyPartCount; i++)
            {
                var bp = outfit.GetBodyPart(i);
                if (bp)
                {
                    var rb = bp.Rigidbody;
                    if (rb)
                    {
                        LizEditorGUIUtil.SetRigidbodyBehavior(rb, status, false, undoLabel);
                    }
                }
            }

            if (singleUndo)
            {
                Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
            }
        }