Scene Loading: Extremely RAM usage and Long Scene Loading Time (4mins).

Hi guys, I am almost done with my project, but I am running into a major snag. When I try to use SceneManager.LoadSceneAsync(“stageName”) from an almost “EMPTY” (one script) game scene, it takes a Ridiculous amount of time and RAM to load one of my game scenes.

This doesn’t happen when I just load stages via the editor, it has a quick load time and no excessive RAM use. I don’t have a lot going on in them. I just use a Master Script Obj that holds all my scripts (Game Manager, Music Manager, and Special Modes) to find and reference all the UI objects and components so I don’t have to manually place them in (I have 90+ stages).

I have MP3 and Wav audio, but I made sure I placed them in the Resources folder and ensured that changed the option from Decompress on load to Streaming and Vorbis Compression. I have tried flushing the memory with an empty game scene but that doesn’t work either. I am stuck guys… Below is a “small” example of my GameManager script.

using UnityEngine;
using System.Collections;
using System.Diagnostics;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour {
   private ButtonScript buttonScript;
    private EnemySpawnManager spawnManager;
    private SlowMotion sloMo;
    private GameObject camParentObj;
    public Button vibrateButton;
    private Camera theCamera;
    public int selectedBoss;
    public int enemyCounter;
    public int startingEnemyCount;
    private int pauseChkNum; //if 0 pause is off.  if 1 pause is on.
    private int theChosenView;
    private int togglechkNum;
    private float[] viewSizes = new float[3];
    private float[] cameraViewYPos = new float[3]; //used to adjust screen upon changing camera view.
    private float fxVal;
    private float musicVal;
    public Image pauseMenu;
    public Text enemynumTxtBox;
    public Button[] viewButtons;
    public GameObject SettingsMenu;
    public GameObject PauseCanvas;
    public GameObject[] onOffText;
    public AudioSource theMusicAudioComponent;
    public AudioSource soundFxPlayer;
    //private BossBehaviorScript BBS;
    private bool _settingsIsActive; 
    public bool _startBossSpawnMinions = false;  //used to keep track of when to to start the boss moving again.
    public bool _ispaused = false;
void Start(){
       //Stopwatch sw = new Stopwatch();
    onOffText = new GameObject[2];
    onOffText[0] = GameObject.FindGameObjectWithTag("ONTXT");
    onOffText[1] = GameObject.FindGameObjectWithTag("OFFTXT");
  vibrateButton = 
    cameraViewYPos[0] = -.77f;
    cameraViewYPos[1]= -.41f;
    cameraViewYPos[2]= -.11f;
    viewButtons = new Button[3];
    viewButtons[0] = GameObject.FindGameObjectWithTag("CloseView").GetComponent<Button>();
    viewButtons[1] = GameObject.FindGameObjectWithTag("RegView").GetComponent<Button>();
    viewButtons[2] = GameObject.FindGameObjectWithTag("WideView").GetComponent<Button>();
    viewSizes[0] = 3.3f;
    viewSizes[1] = 4f;
    viewSizes[2] = 4.7f;
    theCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
    camParentObj = GameObject.FindGameObjectWithTag("CameraContainer");
    //spawnManager = FindObjectOfType<EnemySpawnManager>();
    buttonScript = FindObjectOfType<ButtonScript>();
    //BBS = FindObjectOfType<BossBehaviorScript>();
    sloMo = GetComponent<SlowMotion>();
    enemynumTxtBox = GameObject.FindGameObjectWithTag("EnemyCounter").GetComponent<Text>();
    SettingsMenu = GameObject.FindGameObjectWithTag("SettingsCanvas");
   PauseCanvas = GameObject.FindGameObjectWithTag("PauseCanvas");
   theMusicAudioComponent = 
   soundFxPlayer = 
    togglechkNum = PlayerPrefs.GetInt("ToggleOn");
    theChosenView = PlayerPrefs.GetInt("selectedview");
    musicVal = PlayerPrefs.GetFloat("MusicSettings");
    fxVal = PlayerPrefs.GetFloat("FxSettings");

        //enemyCounter = startingEnemyCount;
        enemyCounter = 0;
        enemynumTxtBox.text = "0" + enemyCounter;
        SetUserCamPos(theChosenView); //Set the cam position.
		//print("GMS Start Time" + ((float)sw.ElapsedMilliseconds / 1000f));
	// Update is called once per frame
	void Update () {

Figured it out by myself… It had absolutely nothing to do with my script… It was related to the asset dependencies of the scenes. I had a prefab that had MANY references to sprites that were related to animations that I didn’t not need on that particular level. I also lowered the texture sizes of some of my sprites because they were ridiculous (some were 20-30mb a piece). After making these changes, my load time went from 4 mins(and/or a auto system reboot) to 10 “SECONDS”. I had someone try to charge me $1400 to fix something this simple… Main lesson, believe in your self, keep learning and keep Tinkering!!!