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 sprites; public Image bg; private void Awake() { instance = this; DontDestroyOnLoad(gameObject); StringEventSystem.Global.Register("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; } } }