Adding a "Fix Now" button to materials using Amplify Shader

Hey,

When using a Unity default shader for particles, the material has a “Required Vertex Streams” section and a “Apply to Systems” button.

This feature is very useful for fixing any particle system that is not set properly.

How could I create such a button for a shader created with Amplify Shader Editor?

ASE has an option to specify a “Custom Editor”. This lets you override how the material is displayed in the inspector.

Here’s the (limited) official Unity documentation on the topic.

And here’s the custom editor Unity’s particle shader uses. The “Apply to Systems” button is buried deep in the DoVertexStreamsArea() function, search for streamApplyToAllSystemsText to find it.

Normally for a custom editor you have to manually list out every material property, and how to display them. But you can also extend an existing material editor class, like ASE’s own, and in your class’s OnGUI() function you should be able to call base.OnGUI(); to get the default ASE material inspector, and then append your own function to add the vertex streams portion.

Unfortunately there’s no easy way to generalize that function, as the order and components used by streams is arbitrary based on how you use them in your specific shader. And thus generally has to be hardcoded into the custom editor. Unity’s has a list of streams that it builds by looking at what features are enabled, and adds the appropriate streams to the list in the explicit order they’re needed by the shader.

2 Likes

Thank you so much for this!