How do you load a ComputeShader in code without using the Resources folder?
I need a way to load a ComputeShader, in code, without the use of a Resources folder.
I'm working on a EditorWindow plugin that requires the use of a ComputeShader. This ComputeShader is only intended to be used from the EditorWindow and no where else. My plugin doesn't add any GameObjects to the scene, and it doesn't create any components to add to any of the existing GameObjects. The only thing my EditorWindow does is run a bake process that will hopefully produce results that can be used by developers to increase the realism of some of the scene's components.
Do to these restrictions, I have found only one way to load the ComputeShader so far, and it goes against the purpose of the ComputeShader only being used by the EditorWindow. The only way I know of loading the ComputeShader is by placing it inside a Resources folder and loading it as a resource that gets cast to a ComputeShader. Using a Resources folder would pass the ComputeShader over to the builds, which is something I really don't want.
Is there anyway to load the ComputeShader in code without the use of a Resource folder?
Answer by lclemens · Dec 30, 2020 at 01:39 AM
Did you ever find an answer to this? I need to do the exact same thing... I'm also making a editor window for a baking process.
Another possibility is to put a field on your GUI that lets users choose your compute shader... but that solution is also sucky if you don't want to confuse people with useless GUI options.
Not really. But, it turned out that I couldn't run the Compute Shader in any kind of async mode. So, in order to stop the Editor from freezing up, I ended putting the bake process into a headless (???) build (a build with no monitors or cameras), that get's launched by the Unity Editor as a separate program. This program would send progress updates to the Unity Editor, and the Editor Window would display the current progress without freezing.
Part of the reason why I split this into it's own build was so that I could launch it as a separate process. That idea was something I copied from the team that built the Light $$anonymous$$ap Baking System.
I created an initial version of this division of labor, but before I ever got around to testing it, some other stuff came up, and then I never touched it again. I did test a few prototypes, so unless they did some changes to the Unity API (which is a real possibility), then I know for a fact that you can create a screenless Unity App, launch that app form the Unity Editor, and have two-way communication between your app and the Unity Editor talk over the network with UDP. I used flatbuffers for my data-format definitions and encoding/decoding needs.
Your answer
Follow this Question
Related Questions
Reading from RWTexture2D in compute shader Unity 0 Answers
How to add a Vector3 to a ComputeBuffer 1 Answer
Use a Editor window to download unitypackage stored on my webserver 0 Answers
How to add Canvas Scaler and Graphic Raycaster to Canvas in code 1 Answer
How to get rect a window of editor? 0 Answers