I’m creating a save manager that does three basic things. 1) Load the first game scene from the start scene. 2) Load a saved game to the last saved scene and checkpoint. 3) Handle a scene change when the player goes through a portal to another scene. Numbers one and two are working as expected. I’m having a problem with number three.
The save manager is a singleton object which is created in the start scene. This is the script that is attached to the portal in another scene. The portal’s name is the name of the new scene.
public class PortalName : MonoBehaviour
{
private string portalSceneName;
private GameObject saveSystem;
private void Awake()
{
saveSystem = GameObject.Find("SaveManager");
portalSceneName = gameObject.name;
}
public void ChangeScenes()
{
if (saveSystem != null)
{
saveSystem.GetComponent<GameSaveSystem>().ChangeScenes(portalSceneName);
}
else
{
Debug.Log("Save Manager not Found!");
}
}
}
This is the change scene script attached to the save manager:
public void ChangeScenes(string newSceneName)
{
UpdateProgressUI(0);
loadSceneCanvas.gameObject.SetActive(true);
LoadDSGameDataFromSceneChange();
StartCoroutine(BeginLoad(newSceneName));
}
The problem is that the portal code is not finding the save manager so it can’t pass the name of the object (which is the new scene’s name) into the ChangeScenes script. Thanks for any help you can offer.