Try to search your question here, if you can't find : Ask Any Question Now ?

Threads in Unity to avoid Animation freeze

HomeCategory: stackoverflowThreads in Unity to avoid Animation freeze
john asked 1 week ago

Every time I load a texture from a saved file, any animation in my scene is frozen until the loading from file is done.
I read so many different opinions about Threads, and none got answers. but I have to load the texture in a different thread to avoid freezing.
My code is attached to a gameobject which is a UI popup window

void Start() {
Texture2D tex = LoadTexFromFile(); //Should be in a diffrent thread that returns a texture
sprite = Sprite.Create(tex, 
                       new Rect(0, 0, tex.width, tex.height), 
                       new Vector2(tex.width / 2, tex.height / 2));

picFrame.GetComponent<Image>().overrideSprite = sprite; }

How do I safely use threads in my code?

1 Answers
Best Answer
Mannu answered 1 week ago
Your Answer

6 + 12 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com