Hi everyone
I’m trying to adjust plugin from the Asset Store to improve performance. This plugin uses default C# managed threads for better UX so that Editor doesn’t freeze while data is generating.
I found bottlenecks in the generation process and want to replace them with burst compiled code.
But I cannot run burst compiled code from C# managed thread.
When I’m running this code from thread:
var job = new MyCustomJob(){ ... }; // this is just IJob
job.Run();
I’m getting this error:
UnityException: CreateJobReflectionData can only be called from the main thread.
Sadly, calling job.Execute();
runs non-bursted job which is even worse than plain C# implementation.
I can’t use FunctionPointers because I’m heavily using NativeArrays which are forbidden with FunctionPointers.
For the same reason I can’t use this approach from Burst docs:
https://docs.unity3d.com/Packages/com.unity.burst@1.7/manual/docs/CSharpLanguageSupport_Lang.html#directly-calling-burst-compiled-code
I’m not trying to do something fancy, just to run(not schedule or smth tricky) burst compiled code from a managed thread. And I don’t mind wrapping code with Jobs to be able to use NativeArrays, but this just doesn’t work.
Any help or suggestions, please?