Home

Awesome

Shader Utils for SRP v2

openupm

Utilities for SRP shaders.

Requirements

File Extensions

Create HLSL and SRP Shader files easily using menu item.

menu item

Preference Settings

Settings can be found in Preferences/Shader Utils for SRP.

pref settings

Advanced Shader GUI

Use StaloSRPShaderGUI as CustomEditor.

CustomEditor "StaloSRPShaderGUI"

shader gui

Advanced Shader Property Attributes

Material Property Wrapper

This is similar to Unity's MaterialPropertyDrawer.

You can write a custom class inherited from MaterialPropertyWrapper (in namespace Stalo.ShaderUtils.Editor) to control the GUI of a material property.

Here's an example:

internal class PostHelpBoxWrapper : MaterialPropertyWrapper
{
    private readonly MessageType m_MsgType;
    private readonly string m_Message;

    public PostHelpBoxWrapper(string rawArgs) : base(rawArgs)
    {
        string[] args = rawArgs.Split(',', StringSplitOptions.RemoveEmptyEntries);

        for (int i = 0; i < args.Length; i++)
        {
            args[i] = args[i].Trim();
        }

        m_MsgType = Enum.Parse<MessageType>(args[0]);
        m_Message = string.Join(", ", args[1..]);
    }

    public override void OnDidDrawProperty(MaterialProperty prop, string label, MaterialEditor editor)
    {
        EditorGUILayout.HelpBox(m_Message, m_MsgType);
    }
}