Quantcast
Channel: Questions in topic: "loadlevelasync"
Viewing all articles
Browse latest Browse all 194

Unity Loading Animation

$
0
0
Hello, I was reading lots of post of loading animations with loadLevelAsync etc. But I could not find a solution for my problem: So at void Start() I create an entire Level String (it goes through a while loop). After that I create an Asset Pool so placing deactivated prefabs on stage (approx. 100 sprite assets). The entire code takes about 2 sec to be done. I tought, okay I call that create function as a coroutine and Unity wont freeze. That worked just fine but the same calculation took 97 seconds. I placed a yield return in the while loop: while (iCurrentPosition < iLevelLength) { float currentPositionPercentage = 1.0f - (iCurrentPosition / iLevelLengthInPix); int iCurrentMin = (int)(iCurrentPosition + ((p_iDifficulty [1] - p_iDifficulty [0]) * currentPositionPercentage) + p_iDifficulty [0]); int iCurrentMax = (int)(iCurrentPosition + ((p_iDifficulty [3] - p_iDifficulty [2]) * currentPositionPercentage) + p_iDifficulty [2]); newDistance = Random.Range (iCurrentMin, iCurrentMax); iCurrentPosition = newDistance; if (amountOfBalks > 0 ) m_strLevelString += "&"; m_strLevelString += newDistance.ToString() + "-" + getBalkString(); amountOfBalks++; yield return ""; } So I guess after yield it saves the position and continuous after the next frame. That would explain why it takes over 97 seconds. What I want is, that Unity shows an UI animation without freezing, and removes it after all sceneloading and calculation from start is done and scene is ready to play. How can I solve that?` Thank you very much for your help! Best regards, Luke

Viewing all articles
Browse latest Browse all 194

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>