Does anyone know how to save the pressed button and not change it even after reloading the scene?
1 Like
using UnityEngine;
using UnityEngine.EventSystems;
public class YourClass : MonoBehaviour
{
public GameObject Button;
public string ButtonName;
public bool ChangeButton = true;
public void RememberButton()
{
if (ChangeButton)
{
Button = EventSystem.current.currentSelectedGameObject;
ButtonName = Button.name;
PlayerPrefs.SetString(ButtonName + “Key” , ButtonName);
}
}
public void Start()
{
if(PlayerPrefs.GetString(ButtonName + “Key”, “Error”) != “Error”) Button = GameObject.Find(PlayerPrefs.GetString(ButtonName + “Key”));
}
}
might Work.