private void OnGUI() { // Make sure everything is setup correctly before displaying sprites GameObject tileMapObject = Selection.activeGameObject; if (tileMapObject) { TileMap tileMap = tileMapObject.GetComponent <TileMap>(); if (tileMap) { if (tileMap.TextureAtlas != null) { RenderSpriteAtlas(tileMap); } else { GUIUtility.ErrorLabel("You must first select a texture atlas"); } } else { GUIUtility.ErrorLabel("You must select a tile map object."); } } else { GUIUtility.ErrorLabel("You must select a tile map object."); } }