I'm experimenting with compute shaders in Unity. A pretty typical thing you wanna do is marshal a buffer of structs back and fourth between C# and HLSL land. Ordinarily you'd have to manually define an identical struct in both C# and HLSL to do this. But Unity provides a convenient [GenerateHLSL(PackingRules.Exact, false)] attribute that you can prepend to any struct and have it auto-generate an HLSL counter-part. The thing is, is I can't figure out a way to trigger this manually via scripting. Right now, I'm forced to manually go Edit > Render Pipeline > Generate Shader Includes Everytime I make changes to the marshaled struct.

Anybody know the function I can call to trigger this via scripts?


  • \$\begingroup\$ I'm thinking of creating a simple Resharper plugin to help automate this process. I'll update my answer when I make some progress. \$\endgroup\$
    – Charly
    Sep 8, 2021 at 1:57


You must log in to answer this question.

Browse other questions tagged .