コード例 #1
0
        public override void OnPostTargetMembersGUI(GUISkin skin)
        {
            GUI.Separator();

            GUIStyle dragDropFieldStyle = new GUIStyle(skin.textArea);

            dragDropFieldStyle.alignment = TextAnchor.MiddleCenter;
            dragDropFieldStyle.richText  = true;

            Rect dropArea = new Rect();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(GUI.MakeLabel("Assign Shape Material [" + GUI.AddColorTag("drop area", Color.Lerp(Color.green, Color.black, 0.4f)) + "]",
                                              false,
                                              "Assigns dropped shape material to all shapes in this rigid body."),
                                dragDropFieldStyle,
                                GUILayout.Height(22));
                dropArea = GUILayoutUtility.GetLastRect();

                bool resetMaterials = GUILayout.Button(GUI.MakeLabel("Reset",
                                                                     false,
                                                                     "Reset shapes material to null."),
                                                       skin.button,
                                                       GUILayout.Width(42)) &&
                                      EditorUtility.DisplayDialog("Reset shape materials", "Reset all shapes material to default [null]?", "OK", "Cancel");
                if (resetMaterials)
                {
                    AssignShapeMaterialToAllShapes(null);
                }
            }
            GUILayout.EndHorizontal();

            GUI.HandleDragDrop <ShapeMaterial>(dropArea, Event.current, (shapeMaterial) => { AssignShapeMaterialToAllShapes(shapeMaterial); });

            GUI.Separator();

            OnShapeListGUI(skin);
            OnConstraintListGUI(skin);
        }
コード例 #2
0
        private void OnContactMaterialsList(GUISkin skin)
        {
            ContactMaterial contactMaterialToAdd    = null;
            ContactMaterial contactMaterialToRemove = null;

            GUILayout.Label(GUI.MakeLabel("Contact Material Manager", 18, true), new GUIStyle(skin.label)
            {
                alignment = TextAnchor.MiddleCenter
            });
            GUILayout.Space(4);
            GUILayout.Label(GUI.MakeLabel("Drag and drop contact materials into the list below to add/enable the contact material in the simulation."),
                            new GUIStyle(skin.textArea)
            {
                alignment = TextAnchor.MiddleCenter
            });
            GUILayout.Space(4);

            GUI.Separator3D();

            GUILayout.BeginVertical();
            {
                if (GUI.Foldout(FoldoutDataEntry, GUI.MakeLabel("Contact Materials [" + Manager.ContactMaterialEntries.Length + "]"), skin))
                {
                    var contactMaterials = Manager.ContactMaterials;
                    using (new GUI.Indent(12)) {
                        foreach (var contactMaterial in contactMaterials)
                        {
                            GUI.Separator();

                            bool foldoutActive = false;

                            GUILayout.BeginHorizontal();
                            {
                                foldoutActive = GUI.Foldout(EditorData.Instance.GetData(Manager, contactMaterial.name), GUI.MakeLabel(contactMaterial.name), skin);
                                using (GUI.NodeListButtonColor)
                                    if (GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListEraseElement.ToString(), false, "Erase this element"),
                                                         skin.button,
                                                         new GUILayoutOption[] { GUILayout.Width(20), GUILayout.Height(14) }))
                                    {
                                        contactMaterialToRemove = contactMaterial;
                                    }
                            }
                            GUILayout.EndHorizontal();

                            if (foldoutActive)
                            {
                                using (new GUI.Indent(12))
                                    BaseEditor <ContactMaterial> .Update(contactMaterial, contactMaterial, skin);
                            }
                        }
                    }
                }
            }
            GUILayout.EndVertical();

            // Note that GetLastRect is used here and it's expecting the begin/end vertical rect.
            GUI.HandleDragDrop <ContactMaterial>(GUILayoutUtility.GetLastRect(),
                                                 Event.current,
                                                 (contactMaterial) =>
            {
                contactMaterialToAdd = contactMaterial;
            });

            GUI.Separator();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(GUI.MakeLabel("Add:"), skin.label);
                contactMaterialToAdd = EditorGUILayout.ObjectField(null, typeof(ContactMaterial), false) as ContactMaterial ?? contactMaterialToAdd;
            }
            GUILayout.EndHorizontal();

            GUI.Separator3D();

            if (contactMaterialToAdd != null)
            {
                Manager.Add(contactMaterialToAdd);
                FoldoutDataEntry.Bool = true;
            }

            if (contactMaterialToRemove != null)
            {
                Manager.Remove(contactMaterialToRemove);
            }
        }