Createing a Uobject in a seperate thread
I need to create several large UTexture2D objects at runtime and fill the mipdata. but doing so freezes the game until the have all been created. And I know that Uobjects currently are not thread safe. Is there anyway safe way to do this in a seperate thread?
asked Oct 21 '14 at 04:04 PM in C++ Programming
I managed to solve this issue pretty simply. and now can create threads in blueprints and in them create Uobjects So here is a hint.
create a structure for jobs to enqueue on the game thread create a : TQueue jobArray; have a function that just Enqueue to this queue. then use it in your thread to enqueue jobs in the game thread. Now in the Tick function have something similar to the following
Tqueue is thread safe so there is no concern about it. and this way you can even design you nodes that to be run on the game thread via blueprints
answered Dec 05 '16 at 09:59 AM
I have solve this issue while writing my own custom Kinect plugin. create your textures outside of the thread code and in the class which you handle the thread or in the actual thread code just keep a pointer to the texture ( UTexture2D* texture ) this way you can simply modify the texture in your code.
answered Dec 13 '16 at 11:04 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here