Here is a C# script for visualizing render bounds. Just attach it to a game object and it will draw the render bounds of the game object and all it’s children. Handy for debugging!

Render Bounds Script Preview

public class RendererBoundsGizmo : MonoBehaviour
    public bool ShowCenter;

    public Color Color = Color.white;

    public bool DrawCube = true;

    public bool DrawSphere = false;

    /// <summary>
    /// When the game object is selected this will draw the gizmos
    /// </summary>
    /// <remarks>Only called when in the Unity editor.</remarks>
    private void OnDrawGizmosSelected()
        Gizmos.color = this.Color;

        // get renderer bonding box
        var bounds = new Bounds();
        var initBound = false;
        if (CBX.Utilities.Helpers.GetBoundWithChildren(this.transform, ref bounds, ref initBound))
            if (this.DrawCube)
                Gizmos.DrawWireCube(, bounds.size);
            if (this.DrawSphere)
                Gizmos.DrawWireSphere(, Mathf.Max(Mathf.Max(bounds.extents.x, bounds.extents.y), bounds.extents.z));

        if (this.ShowCenter)
            Gizmos.DrawLine(new Vector3(bounds.min.x,,, new Vector3(bounds.max.x,,;
            Gizmos.DrawLine(new Vector3(, bounds.min.y,, new Vector3(, bounds.max.y,;
            Gizmos.DrawLine(new Vector3(,, bounds.min.z), new Vector3(,, bounds.max.z));

        var view = SceneView.currentDrawingSceneView;
        var pos =;
        var size = GUIContent(bounds.ToString()));
        GUI.Label(new Rect(pos.x - (size.x / 2), -pos.y + view.position.height + 4, size.x, size.y), bounds.ToString());

And also the code for the GetBoundsWithChildren method.

/// <summary>
/// Gets the rendering bounds of the transform.
/// </summary>
/// <param name="transform">The game object to get the bounding box for.</param>
/// <param name="pBound">The bounding box reference that will </param>
/// <param name="encapsulate">Used to determine if the first bounding box to be calculated should be encapsulated into the <see cref="pBound"/> argument.</param>
/// <returns>Returns true if at least one bounding box was calculated.</returns>
public static bool GetBoundWithChildren(Transform transform, ref Bounds pBound, ref bool encapsulate)
    var bound = new Bounds();
    var didOne = false;

    // get 'this' bound
    if (transform.gameObject.renderer != null)
        bound = transform.gameObject.renderer.bounds;
        if (encapsulate)
            pBound.min = bound.min;
            pBound.max = bound.max;
            encapsulate = true;

        didOne = true;

    // union with bound(s) of any/all children
    foreach (Transform child in transform)
        if (GetBoundWithChildren(child, ref pBound, ref encapsulate))
            didOne = true;

    return didOne;


I have released the v1.2 update to my CBX.GridMapping project.

Unity Asset Store: Asset store
Unty Forums: Fourm thread

Version Notes

Items starting with "Completed" are items that have been fully implemented as they were intended
Items starting with "Partial" are items that have only been partially implemented.


  • Completed - CBXEditorHelpers.toolBarButtonSize need to be replaced with a setting in xml file
  • Completed - Need ability to specify in settings weather user need to hold alt ctrl or shift to draw and erase
  • Completed - For included prefabs you should have mesh generation ones as well as actual prefab *.fbx ones so the user does not wish to take advantage of mesh generation they can have option to use mesh based prefabs.
  • Completed - Should use multiple prefab list files so they can be bundled together and included with prefabs for distribution as a *.unitypackage
  • Completed - Recently used prefab list and recently used materials list should not show the name but rather just 'Select'
  • Completed - Recently used prefabs and material lists need a setting to say weather or not to show the object selection field or weather to just show a button.
  • Completed - Settings for setting the max number of items that a recently used lists can contain.
  • Completed - Need to localize all strings for grid mapping using a localization system
  • Completed - Have settings to specify the max height of the list of recent materials or prefabs
  • Completed - Categorized quick prefab selection
  • Completed - Additional prefab shapes for 2D and 3D
  • Partial - Ability to edit along different axis. Currently it only supports X/Z axis editing with layers extending into the Y plane. Partial support by granting the ability to rotate the map object and still draw
  • Completed - Have option to show recent material & prefab lists displayed as grid of buttons
  • Completed - GridMapping DrawMapInfo method uses a cloned skin from a label and makes it white for highlighting sections. You should not do this because it could cause issues if the skin is different.
  • Completed - Auto scale does not take into account rotation while drawing so a tall obj drawn with no rotation works fine but a tall object draw with 90 rotation along x causes it not to scale properly IE it does not fit within the cell dimensions. This has been fixed
  • Partial - When the map is rotated and user draws the prefabs are not rotated with the map and as such are not drawn in there proper location. This was partially fixed. Prefabs are placed where they should be but positioning the mouse over a grid cell on a map that is rotated is not exact and precice like it is when the map has no rotation. This gets exaderated when the active layer is beyond 3 layers deep. It works but it is not as acurate as I would like it to be.
  • Completed - Full setting customizability for changing grid & guideline colors etc
  • Completed - Tile material creation window needs setting in settings dialog for 'As list' check box as well as default output path etc
  • Completed - Tile material createion should have ability to flip along horiz and vert

v1.0 - v1.1

  • Initial release

Recently I needed to force the inspector to redraw itself from a piece of code outside of a Editor class. The solution I came up with was to call SetDirty on all selected objects of the type I was interested in. The inspector then picked up on the change and refreshed itself immediately. Although this code works under Unity 4 it is a hack and there may be a better way to force the inspector to redraw itself.

var objects = Selection.GetFiltered(typeof(GridMap), SelectionMode.TopLevel);
foreach (var o in objects)

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