E_ElecCompetition/Electrical_inspectionCompet.../Assets/Script/WorkingPersonnel/WorkingPersonnel.cs

41 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WorkingPersonnel : MonoBehaviour
{
public static WorkingPersonnel instance;
[SerializeField] string isWorkingPersonnel;
[SerializeField] GameObject game;
private void Awake()
{
if (instance != null)
{
Destroy(gameObject);
return;
}
instance = this;
DontDestroyOnLoad(gameObject);
}
// Start is called before the first frame update
void Start()
{
if (string.IsNullOrEmpty(PlayerPrefs.GetString("isWorkingPersonnel")))
{
PlayerPrefs.GetString("isWorkingPersonnel", "0");
}
else
{
isWorkingPersonnel = PlayerPrefs.GetString("isWorkingPersonnel");
if (isWorkingPersonnel.Equals("1"))
{
game.SetActive(false);
}
}
}
private void OnDestroy()
{
PlayerPrefs.SetString("isWorkingPersonnel","0");
}
}