using System; using DG.Tweening; using UnityEngine; using UnityEngine.UI; namespace AppUI.Util.Switch { [RequireComponent(typeof(Button))] public class UISwitchToggle : MonoBehaviour { [Header("UI")] [SerializeField] Image background; [SerializeField] RectTransform knob; [Header("Color")] [SerializeField] Color onColor = new Color(0.3f, 0.85f, 0.4f); [SerializeField] Color offColor = new Color(0.7f, 0.7f, 0.7f); [Header("Move")] [SerializeField] float knobOnX = 30f; [SerializeField] float knobOffX = -30f; [SerializeField] float duration = 0.2f; bool isOn; Action onValueChanged; Button btn; void Awake() { btn = GetComponent