Skip to content

Scaled Time

Many effects, like most of the the UV and Mesh effects, will use Time to animate. This Time value is scaled by default, meaning that if you pause the game, the effects will stop animating. In some cases you’ll want full control over the time of your materials, either for this reason, or for some other custom reason.

The first step is to enable Use Custom Time in the Advanced Configuration of the Materials you want to change the time behaviour of.

The Advanced Configuration panel of the Material Inspector with Use Custom Time ticked

A material with Use Custom Time stops following Unity’s time and reads a global value instead, so something in your scene has to set it, or its animations won’t move. The asset includes the Shader Global Time Controller component, which feeds it unscaled time. Add it to an active Gameobject:

The Shader Global Time Controller component

For your own logic, set the same global from a script, keeping the same four speeds:

float t = myTime;
Shader.SetGlobalVector("allIn13DShader_globalTime", new Vector4(t / 20f, t, t * 2f, t * 3f));

And as a reminder, to have materials visually update in the Scene view check the Always Refresh option in the top right corner of the Scene Window:

The dropdown of Skybox, Fog, Flares and other effects at the top right of the Scene Window, with Always Refresh ticked