I am designing a mobile application and with the saving wrapper and everything that we were provided with. There is a load last scene function but I don’t want to do it that way. First comes my start scene then the load scene and then the game scene. So I hooked up the start button to load the load scene
And I made some code like this to make sure load scene loads the default scene and in the starting it doesn’t load anything but a new game.
IEnumerator LoadLast()
{
if(GetComponent<SavingSystem>().LoadLastScene(defaultSaveFile)!=null)
{
yield return GetComponent<SavingSystem>().LoadLastScene(defaultSaveFile);
}
else
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(2);
while (!asyncLoad.isDone)
{
yield return null;
}
}
}
but it is showing object reference error when starting for the first time. But I am checking if it is null or not