I’m a beginner. I’m working on a little game and I have 2 simple scene. First one being Main Scene and second one being Battle Scene(I’m doing turn-based battle). So what im trying to do is that when player goes to battle, I change my scene to battle scene and when the battle is over, I want to turn back to Main Scene right as it was before the battle scene was triggered. I used LoadScene() but they are just restarting the scene. Help me
You could add something like this
public string SceneName;
public gameObject Player;
void Update()
{
DontDestroyOnLoad(transform.gameObject);
ActualSceneName = SceneManager.GetActiveScene().name;
if (ActualSceneName == Battling)
{
Player.GetComponent<Image>().enabled = false;
} else {
Player.GetComponent<Image>().enabled = true;
}
}
If the player has a SpriteRenderer change Image for SpriteRenderer.
Also you’ll need to set the Player GameObject as the Player itself (the player object need to have the script. And also you’ll need:
using UnityEngine.UI;
using UnityEngine.SceneManagement;