Is there any way to package shader files into a dll?

I want to package shader files and c# script into one dll to make the project more clean . So is there any way to package them into one?

Shaders are assets that have nothing to do with managed code. So it makes no sense to “pack” it into a managed DLL. It equally makes no sense to pack a mesh, material or texture into a DLL. In classical application development it is common to pack “resources” into DLLs. However Unity does not provide any means to work with embedded resources in DLL files. Assets need to be imported into the AssetDatabase of your Unity project in order to be usable.

Though that doesn’t mean that you can’t pack embedded resources yourself into your DLL if you compile it yourself in VS and just import it into Unity. However you have to load those things yourself manually at runtime. This may be a huge problem because it would not work on every platform (IL2CPP and all other AOT platforms would be out), also not all assettypes can be imported / loaded at runtime. Shaders would probably need to be precompiled. Though I’m not sure if you could actually load them at runtime.

So on the bottom line I don’t think this makes much sense.

1 Like