Technical Notes

Favorites

Painter’s Favorites list is a visual representation of data stored in a Scriptable Singleton instance. When the instance is saved, the data is serialized to the file system.

The serialization is performed like any other Unity serialization: references to scene Objects are lost. This creates a problem because TilePlus tiles found in Multiple-selection picks from a Scene in the hierarchy are scene objects: saved with the scene but they do not have corresponding Project assets.

Instead, these tiles are serialized to JSON using EditorJsonUtility.ToJson, and the output string from that method is what’s stored. When the Scriptable Singleton’s instance is loaded, this string is used to create and populate a new TilePlus tile which can now be painted.

This approach removes the need to create many new asset files for the TilePlus tiles, which makes little sense for a transient storage container such as Favorites.

The downside is that every time that a new Favorite item is added to the list, the entire list is serialized and saved. Each Multiple-selection Pick in Favorites has two potentially large items:

The Icon is saved as a PNG and is compressed. The JSON data are strings in a condensed format.

Keeping response times short is the main reason that Favorites is limited to 32 entries.

If the process fails in any way and null tiles end up in reconstituted Multiple-selection Picks, then the entire Pick is discarded.

The list of Favorites will be automatically truncated if the number of Favorites exceeds 32 entries when the Favorites data is saved to the file system.

Agressive Mode

Aggressive Mode is controlled by a Settings panel toggle. It’s a workflow accelerator that you’ll either love or hate. What does it do?

Painter monitors what’s currently selected. In Unity Editor-land, the selection is what you see in an inspector. Usually, it’s something from the Project or Hierarchy windows.

If you’re using Painter with an active Action(Paint, Erase, etc.) and a Tilemap is selected in the Hierarchy window and change the selection to anything else, for example, something in a Project folder, then when you return to selecting a Tilemap again and wish to continue using Painter you normally must at least click an Action button such as Paint or Erase in order to work in the Scene view again.

Aggressive Mode detects these sort of selection changes, and in most cases will change the Editor tool to TilePlus Painter and reactivate the previously used Action button.

Aggressive mode tries to detect if the UTE is active at the same time as Painter. If so, and if the one of the UTE’s own tools is active (various things determine that) then Aggressive Mode is automatically inhibited.

If you find this accelerator annoying just shut it off.

Updating in Play

Painter usually is mostly dormant in Play mode.
If you’re concerned about eliminating ALL effects that Painter may have in Play mode, just close the Painter window. When the window is open there are internal events that aren’t intercepted during Play.

If you want to be able to examine the fields of a TilePlus tile during play mode, ensure that Update In Play is active in the Settings panel by clicking its checkbox on (note that this is the default state).

Doing so will allow inspectors to update in Play mode.

Validate Tilemaps in Play appears when Update In Play is checked. Its default state is ON.

Updating inspectors can run into the situation where a Tilemap is deleted in Play mode. This would cause a null reference exception since Painter would still be trying to examine that tile. Hence, when Update in Play is checked, Unity’s Hierarchy Changed callback is used to test for adding/removing Tilemaps.

These tests do take time and if you don’t need these tests, uncheck Validate Tilemaps in Play but be aware that null reference exceptions can occur and cannot be considered an error or bug.

Painter Exclusive Mode

The TilePlus Configuration dialog has a checkbox for “Painter Exclusive” and there’s a corresponding option button at the bottom of the Painter window.

Side note: The convention in the TilePlus system is that a configuration item is in the TilePlus configuration if it at all affects that system even if the configuration item involves Painter.

This option controls certain issues that can occur when both Tile+Painter and the UTE are both open at the same time:

Setting this option ON means that Painter will have exclusive control in the Scene and using the Palette won't switch Editor Tools.

Use the '+' button at the bottom of the Painter window to turn this mode on or off quickly.