Skip to content

Stratkit Play Mode Material Restorer

Editor tool that keeps material assets unchanged after play mode.

In the Editor, code that changes a material asset at runtime (for example Material.SetFloat on a material loaded from a sub-scene or a config) changes the .mat file itself, and the change stays after play mode ends. MaterialPlayModeRestorer copies the listed materials when play mode starts and copies the values back when it ends.

Setup

  1. Create a GameObject with the EditorOnly tag in the first scene of the game, for example as a prefab instance in the initialization scene.
  2. Add the MaterialPlayModeRestorer component to it.
  3. Add every material that changes during play mode to TargetMaterials.

Materials are stored by GUID (MaterialGuidReference), so the list does not make them dependencies of the scene or of Addressables. The asset validation checks that the object has the EditorOnly tag and that every listed material exists.

Set TemporarilyDisabled to keep the changes made in play mode, for example when tuning material values.