Allow shaders with 'time' variable to update in editor

Hi all,

I am have a shader that uses the _Time unity passed in value and I would like to see this material change and update in the editor (for example I might have a water texture and want to change settings without running the game to examine the changes).

I have tried attaching a script to the gameobject with the [ExecuteInEditMode] flag. but this only calls that script, it does not tick the shader time.

I have looked in the shader settings but could not find a way to do this.

I have also tried setting the global time variable like so:

var time = (float)EditorApplication.timeSinceStartup;   
Vector4 vTime = new Vector4( time / 20, time, time*2, time*3);
Shader.SetGlobalVector( "_Time", vTime );

and also setting it straight in shader, but it can not be found:

if( editorMaterial.HasProperty( "_Time" ) )
{
    Debug.Log( "has time" ); //This is never printed
}

Has anyone done this before? It seems like it should be something quite simple that I am missing.

Instead of setting time to shader, create new parameter (like _Phase("_Phase", Float) = 0). And then set time value directly to this parameter.

var time = Application.isEditor?(float)EditorApplication.timeSinceStartup:Time.time;
Shader.SetFloat("_Phase", time );

or

var time = Application.isEditor?(float)EditorApplication.timeSinceStartup:Time.time;
Vector4 vTime = new Vector4( time / 20, time, time*2, time*3);
Shader.SetVector("_Phase", time );