public static PropertyGUI Material(string materialDirectory, bool allowAlpha = false, MaterialSelectorGUI.ColorModeSet colorModeSet = MaterialSelectorGUI.ColorModeSet.DEFAULT, bool colorOnly = false) { return((Property property) => { GUILayout.BeginHorizontal(); AlignedLabel(property); GUILayout.FlexibleSpace(); // TODO: magic numbers RectOffset tagFieldStyleMargin = tagFieldStyle.Value.margin; Rect buttonRect = GUILayoutUtility.GetRect(150, 150); Rect textureRect = new Rect( buttonRect.xMin + 20, buttonRect.yMin + 20, buttonRect.width - 20 * 2, buttonRect.height - 20 * 2); if (GUI.Button(buttonRect, " ", tagFieldStyle.Value)) { MaterialSelectorGUI materialSelector = GUIManager.guiGameObject.AddComponent <MaterialSelectorGUI>(); materialSelector.title = "Change " + property.name; materialSelector.rootDirectory = materialDirectory; materialSelector.highlightMaterial = (Material)property.value; materialSelector.allowAlpha = allowAlpha; materialSelector.colorModeSet = colorModeSet; materialSelector.colorOnly = colorOnly; materialSelector.handler = (Material mat) => { property.setter(mat); // skip equality check, it could be the same material with a different color }; } MaterialSelectorGUI.DrawMaterialTexture((Material)property.value, textureRect, allowAlpha); GUILayout.EndHorizontal(); }); }
private void DrawPaint(VoxelFace paint, Rect rect) { float rotation = VoxelFace.GetOrientationRotation(paint.orientation) * 90; Vector2 scaleFactor = Vector2.one; if (VoxelFace.GetOrientationMirror(paint.orientation)) { scaleFactor = new Vector2(-1, 1); rotation += 90; } Matrix4x4 baseMatrix = GUI.matrix; RotateAboutPoint(rect.center, rotation, scaleFactor); MaterialSelectorGUI.DrawMaterialTexture(paint.material, rect, false); MaterialSelectorGUI.DrawMaterialTexture(paint.overlay, rect, true); GUI.matrix = baseMatrix; }