public static void DrawBorder(Rect area, float left, float right, float top, float bottom, Color color) { GUIEx.PushColor(color); // Top UnityEngine.GUI.DrawTexture(new Rect(area.xMin + top, area.yMin, area.width - top * 2.0f, top), GUIEx.White); // Bottom UnityEngine.GUI.DrawTexture(new Rect(area.xMin + bottom, area.yMax - bottom, area.width - bottom * 2.0f, bottom), GUIEx.White); // Left UnityEngine.GUI.DrawTexture(new Rect(area.xMin, area.yMin, left, area.height), GUIEx.White); // Right UnityEngine.GUI.DrawTexture(new Rect(area.xMax - right, area.yMin, right, area.height), GUIEx.White); GUIEx.PopColor(); }
public static bool ImageButton(Texture2D image, GUIStyle style, params GUILayoutOption[] options) { Color color = Color.black; GUIStyle labelStyle = new GUIStyle(style); Rect labelRect = GUILayoutUtility.GetRect(new GUIContent(image), style, options); if (GUIEx.IsHovering(labelRect)) { color = Color.blue; } GUIEx.PushColor(color); UnityEngine.GUI.DrawTexture(labelRect, image, ScaleMode.ScaleToFit); GUIEx.PopColor(); return(GUIEx.WasClicked(labelRect, 0)); }
public static void DrawLines(Vector2[] points, Color[] colors, float width) { ThrowIf.ArgumentIsNull(points, "points"); ThrowIf.ArgumentIsNull(colors, "colors"); ThrowIf.False(points.Length == colors.Length, "Points and colors array must be the same length."); for (int i = 0; i < points.Length; ++i) { Vector2 start = points[i]; Vector2 end = points[MathEx.Wrap(i + 1, 0, points.Length - 1)]; Color color = colors[i]; if (Mathf.Abs(start.x - end.x) > Mathf.Abs(start.y - end.y)) { GUIEx.DrawBox(new Rect(start.x, start.y, end.x - start.x, width), color); } else { GUIEx.DrawBox(new Rect(start.x, start.y, width, end.y - start.y), color); } GUIEx.PopColor(); } }
public static void DrawBox(Rect area, Color backgroundColor) { GUIEx.PushColor(backgroundColor); UnityEngine.GUI.DrawTexture(area, GUIEx.White); GUIEx.PopColor(); }