using UnityEngine; using UnityEngine.UI; public class DropdownCtrl : MonoBehaviour { [SerializeField] Sprite on; [SerializeField] Sprite off; [SerializeField] Image image; [SerializeField] bool isPixels; [SerializeField] float[] pixels; private void OnEnable() { image.sprite = on; if (isPixels) { image.pixelsPerUnitMultiplier = pixels[1]; } } private void OnDestroy() { image.sprite = off; if (isPixels) { image.pixelsPerUnitMultiplier = pixels[0]; } } }