Code: Select all
private void Start()
{
animating = true;
backGroundThread = new Thread(AnimateIt);
backGroundThread.Start();
StartCoroutine(LoadScene());
}
private void OnDestroy()
{
animating = false;
}
IEnumerator LoadScene()
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(gotoScene.ToString(), LoadSceneMode.Single);
asyncLoad.allowSceneActivation = false;
while (!asyncLoad.isDone)
{
Debug.Log(asyncLoad.progress);
if (asyncLoad.progress >= 0.9f)
{
yield return new WaitForSeconds(0.5f);
asyncLoad.allowSceneActivation = true;
}
yield return null;
}
yield return null;
Debug.Log("Out Of Loops");
Destroy(gameObject);
}
public void AnimateIt()
{
int currentFrame = 0;
while (animating)
{
int frame = (int)(currentFrame % frameList.Count);
frameSprite.sprite = frameList[frame];
currentFrame++;
Thread.Sleep((int)((frameRate / 60)*1000));
}
}
< /code>
Bearbeiten ------
Das Original ist super einfach. Es ist nur eine Ladung und die Animation wird nur mit einem Animator durchgeführt. Sie können im Video sehen, dass die Animation auf dem Animator einfriert. Sie können sehen, dass die während der Schleife nicht richtig zu schleifen scheint. Es geht von 0 - 0,9 nach 7 Sekunden ohne Schleife aus, um den Fortschritt < /p>
hier zu zeigen.public void SetUp(LOCATIONS _gotoScene)
{
gotoScene = _gotoScene;
DontDestroyOnLoad(gameObject);
}
void FadeOnfinished()
{
StartCoroutine(LoadScene());
}
IEnumerator LoadScene()
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(gotoScene.ToString(), LoadSceneMode.Single);
asyncLoad.allowSceneActivation = false;
Debug.Log("Going to Load");
while (!asyncLoad.isDone)
{
Debug.Log("Loading: "+ asyncLoad.progress * 100 + "%");
if (asyncLoad.progress >= 0.9f)
{
yield return new WaitForSeconds(0.5f);
asyncLoad.allowSceneActivation = true;
}
yield return null;
}
yield return null;
Debug.Log("Loaded");
animator.SetTrigger("Off");
}