UnityGameProjectsCode / RelianceGame / Save Data Control / ActivateBlocker.cs
ActivateBlocker.cs
Raw
using UnityEngine;

public class ActivateBlocker : MonoBehaviour //used for the continue button on the main menu. Decides when the button should be unusable based on file names from the save file manager
{
    private SaveFileManager saveMgr;
    public GameObject blocker;
    private ButtonTransition transition;

    private void Awake()
    {
        saveMgr = GameObject.Find("Persistent Object").GetComponent<SaveFileManager>();
        transition = GetComponent<ButtonTransition>();
    }

    private void Start()
    {
        if (saveMgr.saveFileName == "")
        {
            blocker.SetActive(true);
            transition.transitionActive = false;
        }
    }

    public void CheckSaves()
    {
        if (saveMgr.fileNames.Count == 0)
        {
            blocker.SetActive(true);
            transition.transitionActive = false;
        }

        if (!saveMgr.fileNames.Contains(saveMgr.saveFileName))
        {
            blocker.SetActive(true);
            transition.transitionActive = false;
        }
    }
}