45 lines
1.1 KiB
C#
Raw Normal View History

2025-03-18 15:22:05 +08:00
using QFramework;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIBg : MonoBehaviour
{
public static UIBg instance;
public List<Sprite> sprites;
public Image bg;
private void Awake()
{
instance = this;
DontDestroyOnLoad(gameObject);
StringEventSystem.Global.Register<string>("BgChange", OnBgChange).UnRegisterWhenGameObjectDestroyed(this);
}
private void OnBgChange(string value)
{
switch (value)
{
case "White":
bg.sprite = null;
bg.color = Color.white;
break;
case "Black":
bg.sprite = null;
bg.color = Color.black;
break;
case "Grey":
bg.sprite = sprites[0];
bg.color = Color.white;
break;
case "Gradient":
bg.sprite = sprites[1];
bg.color = Color.white;
break;
}
}
}