The scene always goes back to the first scene (String named SpriteName)
I'm creating an Escape game, and I'm making a system in which when I click on an object, I go to its zoom scene, and when I click the return button, it is to go back to the scene in which the object is. However, whenever I am in the second scene, it returns to the first scene instead of this second. How can I fix it? This is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonHandler : MonoBehaviour
{
private DisplayImage currentDisplay;
private float initialCameraSize;
private Vector3 initialCameraPosition;
public string SpriteName;
void Start()
{
currentDisplay = GameObject.Find("displayImage").GetComponent<DisplayImage>();
initialCameraSize = Camera.main.orthographicSize;
initialCameraPosition = Camera.main.transform.position;
}
public void OnRightClickArrow()
{
currentDisplay.CurrentWall = currentDisplay.CurrentWall + 1;
}
public void OnLeftClickArrow()
{
currentDisplay.CurrentWall = currentDisplay.CurrentWall - 1;
}
public void OnClickZoomReturn()
{
GameObject.Find("displayImage").GetComponent<DisplayImage>().CurrentState = DisplayImage.State.normal;
currentDisplay.GetComponent<SpriteRenderer>().sprite =
Resources.Load<Sprite>("Sprites/" + SpriteName);
Camera.main.orthographicSize = initialCameraSize;
Camera.main.transform.position = initialCameraPosition;
}
}
Comment