c# – unity – playing animation in heavy load and in parallel

I’m basically having a large amount of code for UI, and it seems to be making my animation freezeup for a bit. I can’t write paste the whole code here, but, here’s an explanation of what’s going on:

  1. PanRot is a panel that has an animator component attached to it, and all it does it play’s the infinite rotation animation. It rotates 360 deg on it’s z axis, it’s basically a loading animation.
  2. MainUI is the class that builds all the list and components for my app
  3. Main is the parent class, where both these components come together for the app.

So, basically what I want to do is, play the loading animation, while the MainUI is building the main ui. Considering the large amount of lists that I have, and some fancy button, it takes about 2 seconds for the UI to build. (It also has some network requests), so, I have the pseudocode here that shows it:

Main {
   Instantiate(PanRot, gameObject.transform);

Since the animator is attached to PanRot, the animation panel appears and starts playing the animation immediately. The problem is, while the UI is building, the rotation animation freezes. It almost looks as if, the UI stuff is all done in a single thread. So, I need to run the animation in a parallel thread if it is possible. How to handle this for unity? (Also, the StartBuilding(MainUI) isn’t a code I can do in a coroutine, if that at all is a possible solution). Thanks in advance, please let me know what can I do about this.