chip-game/Assets/Scripts/VisibilityByPrefs.cs
2026-01-12 09:36:17 +03:00

42 lines
850 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class VisibilityByPrefs : MonoBehaviour
{
[SerializeField] string prefsKey;
[SerializeField] int enabledValue;
[SerializeField] List<Graphic> visibleOnEnable;
private void OnEnable()
{
InvokeRepeating("refresh", 0, 3);
}
void refresh()
{
if (PlayerPrefs.GetInt(prefsKey) == enabledValue)
{
foreach (Graphic g in visibleOnEnable)
{
Color c = g.color;
c.a = 1;
g.color = c;
}
}
else
{
foreach (Graphic g in visibleOnEnable)
{
Color c = g.color;
c.a = 0;
g.color = c;
}
}
}
}