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?