So i’ve read a lot of stuff about loading a level without lag. I have many scenes in my game so when i start loading multiple scenes one after another than it starts lagging after i load the 4-5 scene. This is just how my game is set up since its a color scheme game. So you choose a color thats off and it loads the next scene with different colors. I tried using loadlevelasync and it doesnt really do anything that i want it to do. Here’s the script for the load for async.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class LoadAsync : MonoBehaviour {
AsyncOperation async;
int[] levelNumbers = new int[15]{3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
void start ()
{
StartCoroutine ("load");
}
private IEnumerator load (){
int randomIndex = Random.Range (0, levelNumbers.Length);
Debug.LogWarning("ASYNC LOAD STARTED - " +
"DO NOT EXIT PLAY MODE UNTIL SCENE LOADS... UNITY WILL CRASH");
async = Application.LoadLevelAsync(levelNumbers [randomIndex]);
async.allowSceneActivation = false;
yield return async;
}
public void onClick()
{
int randomIndex = Random.Range (0, levelNumbers.Length);
async = Application.LoadLevelAsync(levelNumbers [randomIndex]);
async.allowSceneActivation = true;
}
}
It works without errors but when i play the game it still lags bad. Is there any possible way to get the darn game to not lag so bad??