Website may be up and down over next few months. I'm currently doing a complete overhaul of everything. Going back to simple individual .htm pages, new overall site theme, sanitizing and cleaning up html of all pages and blog posts, attempting to implement a new tooling and publishing system etc etc.

The FillRectangle helper methods allow you to draw a filled rectangles inside OnGUI methods.

        /// <summary>
        /// Draws a filled rectangle.
        /// </summary>
        /// <param name="rect">
        /// A <see cref="Rect"/> type that defines the bounds of the rectangle to draw.
        /// </param>
        public static void FillRectangle(Rect rect)
        {
            FillRectangle(rect, GUI.color);
        }

        /// <summary>
        /// Draws a filled rectangle.
        /// </summary>
        /// <param name="rect">
        /// A <see cref="Rect"/> type that defines the bounds of the rectangle to draw.
        /// </param>
        /// <param name="color">
        /// The color of the rectangle.
        /// </param>
        public static void FillRectangle(Rect rect, Color color)
        {
            // Store current GUI color, so we can switch it back later,
            // and set the GUI color to the color parameter
            var savedColor = GUI.color;
            GUI.color = color;

            // Finally, draw the actual rectangle.
            GUI.DrawTexture(rect, Texture2D.whiteTexture, ScaleMode.StretchToFill);

            // We're done.  Restore the GUI matrix and GUI color to whatever they were before.
            GUI.color = savedColor;
        }

Add comment



biuquote
  • Comment
  • Preview
Loading






Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume