public override void OnPreTargetMembersGUI() { var skin = InspectorEditor.Skin; GUILayout.Label(GUI.MakeLabel("Debug render manager", 16, true), GUI.Align(skin.label, TextAnchor.MiddleCenter)); GUI.Separator(); var newRenderState = GUI.Toggle(GUI.MakeLabel("Debug render shapes"), Manager.RenderShapes, skin.button, skin.label); if (newRenderState != Manager.RenderShapes) { Manager.RenderShapes = newRenderState; EditorUtility.SetDirty(Manager); } GUI.MaterialEditor(GUI.MakeLabel("Shape material"), 100, Manager.ShapeRenderMaterial, skin, newMaterial => Manager.ShapeRenderMaterial = newMaterial, true); GUI.Separator(); using (new GUILayout.HorizontalScope()) { Manager.RenderContacts = GUI.Toggle(GUI.MakeLabel("Render contacts"), Manager.RenderContacts, skin.button, skin.label); Manager.ContactColor = EditorGUILayout.ColorField(Manager.ContactColor); } Manager.ContactScale = EditorGUILayout.Slider(GUI.MakeLabel("Scale"), Manager.ContactScale, 0.0f, 1.0f); GUI.Separator(); Manager.ColorizeBodies = GUI.Toggle(GUI.MakeLabel("Colorize bodies", false, "Every rigid body instance will be rendered with a unique color (wire framed)."), Manager.ColorizeBodies, skin.button, skin.label); Manager.HighlightMouseOverObject = GUI.Toggle(GUI.MakeLabel("Highlight mouse over object", false, "Highlight mouse over object in scene view."), Manager.HighlightMouseOverObject, skin.button, skin.label); Manager.IncludeInBuild = GUI.Toggle(GUI.MakeLabel("Include in build", false, "Include debug rendering when building the project."), Manager.IncludeInBuild, skin.button, skin.label); }
public void OnInspectorGUI(bool onlyNameAndMaterial = false) { var skin = InspectorEditor.Skin; if (!onlyNameAndMaterial) { GUILayout.Space(4); using (GUI.AlignBlock.Center) GUILayout.Label(GUI.MakeLabel("Create visual tool", 16, true), skin.label); GUILayout.Space(2); GUI.Separator(); GUILayout.Space(4); } GUILayout.BeginHorizontal(); { GUILayout.Label(GUI.MakeLabel("Name:", true), skin.label, GUILayout.Width(64)); Name = GUILayout.TextField(Name, skin.textField, GUILayout.ExpandWidth(true)); } GUILayout.EndHorizontal(); GUI.MaterialEditor(GUI.MakeLabel("Material:", true), 64, Material, skin, newMaterial => Material = newMaterial); GUI.Separator(); if (!onlyNameAndMaterial) { var createCancelState = GUI.CreateCancelButtons(Preview != null, skin, "Create new shape visual"); if (createCancelState == GUI.CreateCancelState.Create) { CreateShapeVisual(); } if (createCancelState != GUI.CreateCancelState.Nothing) { PerformRemoveFromParent(); return; } } }
public override void OnPostTargetMembersGUI(GUISkin skin) { var shapeVisual = ShapeVisual.Find(Shape); if (shapeVisual == null) { return; } GUI.Separator(); if (!GUI.FoldoutEx(EditorData.Instance.GetData(Shape, "Visual", entry => entry.Bool = true), skin.button, GUI.MakeLabel("Shape Visual", 12, true), new GUIStyle(skin.label) { alignment = TextAnchor.UpperCenter })) { return; } GUI.Separator(); GUILayout.Space(6); Undo.RecordObjects(shapeVisual.GetComponentsInChildren <MeshRenderer>(), "Shape visual material"); var materials = shapeVisual.GetMaterials(); if (materials.Length > 1) { var distinctMaterials = materials.Distinct().ToArray(); using (GUI.AlignBlock.Center) { GUILayout.Label(GUI.MakeLabel("Displays material if all materials are the same <b>(otherwise None)</b> and/or assign new material to all objects in this shape."), new GUIStyle(skin.textArea) { alignment = TextAnchor.MiddleCenter }, GUILayout.Width(Screen.width - 60)); } GUI.MaterialEditor(GUI.MakeLabel("Common material:", true), 128, distinctMaterials.Length == 1 ? distinctMaterials.First() : null, skin, newMaterial => shapeVisual.SetMaterial(newMaterial)); GUILayout.Space(6); GUI.Separator(); using (GUI.AlignBlock.Center) GUILayout.Label(GUI.MakeLabel("Material list", true), skin.label); GUI.Separator(); } for (int i = 0; i < materials.Length; ++i) { var material = materials[i]; var showMaterialEditor = materials.Length == 1 || GUI.Foldout(EditorData.Instance.GetData(Shape, "VisualMaterial" + i), GUI.MakeLabel(material.name), skin); if (showMaterialEditor) { GUI.MaterialEditor(GUI.MakeLabel("Material:", true), 64, material, skin, newMaterial => shapeVisual.ReplaceMaterial(i, newMaterial)); } GUI.Separator(); } }