Question by
heyx3 · Dec 11, 2018 at 12:47 AM ·
editor-scriptingshader programmingcompilecompute shader
How do I generate and compile a compute shader in the editor?
I'm working on an editor extension for a custom GPU particle system. The system generates source code for a compute shader, and I need to turn that source into a ComputeShader instance. Basically, I'm looking for the ComputeShader equivalent of UnityEngine.ShaderUtils.CreateShaderAsset()
.
I know I could save the shader to a ".compute" file and manually refresh AssetDatabase, but there are two problems with this approach:
I have to go through the hard drive and then wait for AssetDatabase to catch it, which is slow
This shader is ultimately going to be attached to a ScriptableObject in a ".asset" file; it will not have its own file on the disk.
Comment