Untitled
unknown
csharp
3 years ago
1.5 kB
12
Indexable
public class ThemeGame : MonoBehaviour
{
public ImageType typeImage = ImageType.None;
public Image targetGraphic;
public TextMeshProUGUI textColorTMP;
public List<Color> colorTextTMP;
public List<Sprite> themeSprite;
public ThemeType themeType;
private void OnValidate()
{
if (targetGraphic == null)
{
targetGraphic = GetComponent<Image>();
}
}
private void Start()
{
ThemeHandleEventManager.OnThemeChangeHandle += this.ChangeTypeEventHandle;
}
private void OnDestroy()
{
ThemeHandleEventManager.OnThemeChangeHandle -= this.ChangeTypeEventHandle;
}
private void ChangeTypeEventHandle(ThemeType theme)
{
this.themeType = theme;
if (targetGraphic != null && themeSprite.Count >= 2)
{
targetGraphic.sprite = themeSprite[(int)themeType];
if (themeSprite[(int)themeType] == null)
targetGraphic.enabled = false;
else
targetGraphic.enabled = true;
} else
{
}
if (textColorTMP != null && colorTextTMP.Count >= 2)
{
Color color = colorTextTMP[(int)themeType];
color.a = 1;
textColorTMP.color = color;
}
if (typeImage == ImageType.SetNativeSize)
{
targetGraphic.SetNativeSize();
}
}
}Editor is loading...