Setting Tile Palette background color in Unity


Since Unity 2019.3.1f1 Tile Palette window has solid black background like this:

It is very inconvenient, especially is some of your tiles are black or very dark. In this tutorial you will learn how to hack Unity editor to make background color changeable.

First, I was looking for way how to change black color to something else – for example grey. But what in case, you have grey tiles? Then they will not be visible again. So, best would be to find way, how users can change background color by themselves, based on their needs.

Tile Palette window code is located in file GridPaintPaletteWindow.cs built-in package com.unity.2d.tilemap. This package is located in your Unity installation on this path: Unity\2019.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.2d.tilemap\Editor\

Open file GridPaintPaletteWindow.cs and locate this part of code in onGUI() method:

EditorGUILayout.BeginHorizontal();
float leftMargin = (Screen.width / EditorGUIUtility.pixelsPerPoint - TilemapEditorTool.tilemapEditorToolsToolbarSize) * 0.5f;
GUILayout.Space(leftMargin);
EditorGUILayout.EditorToolbar(TilemapEditorTool.tilemapEditorTools);
GUILayout.Space(leftMargin);
EditorGUILayout.EndHorizontal();

And change it to this:

EditorGUILayout.BeginHorizontal();
float leftMargin = (Screen.width / EditorGUIUtility.pixelsPerPoint - TilemapEditorTool.tilemapEditorToolsToolbarSize) * 0.5f;
GUILayout.Space(leftMargin);
EditorGUILayout.EditorToolbar(TilemapEditorTool.tilemapEditorTools);
previewUtility.camera.backgroundColor = EditorGUILayout.ColorField(previewUtility.camera.backgroundColor);  // <--- CHANGE!
GUILayout.Space(leftMargin);
EditorGUILayout.EndHorizontal();

Now your Tile Palette window has additional tool – color picker – that changes background color like this:


2 responses to “Setting Tile Palette background color in Unity”

  1. At least as of Unity version 2022.3.16f1, you can edit the colors in in the Preferences menu under Analysis -> Colors. It is the top option, 2D -> Tile Palette Background

Leave a Reply

Your email address will not be published. Required fields are marked *