top of page
Search

Support for Arbitrary Shader Parameters in Build

Chris Leu

During development it became apparent that we needed to review all shader parameters at build-time, and have those values available to scripts at runtime.

This would be trivial if UnityEditor.ShaderUtil.GetAllShaderInfo() was available in build, however the UnityEditor namespace is not in any way available in build.


We can use two simple scripts two circumvent this problem, one to be present in build-time and capture the shaders in editor, and a serialized scriptable object to provide those parameters in build.


To start, we can create a simple inspector to manage the system.


Following which, we can create the manager itself. The ShaderPropertySniffer is only conditionally compiled, so the editor references will only be present in editor. However, before being removed, RefreshShaderLibrary() captures all shader data.

This data is inserted into a simple serialized asset, which is then marked as dirty, saved, and refreshed, so the latest data will be available in build.


10 views0 comments

Recent Posts

See All

Comments


bottom of page