using Fort23.Core; using Fort23.Mono; using UnityEngine; public class ItemWidgetBasic : UIComponent, IScorllListWidget { public LongPressBtn longPressBtn; public ButtonAnimation animation = null; protected RectTransform _rectTransform; public System.Action OnClick { get { return onClick; } set { onClick = value; if (onContinueClick != null || onClick != null) { if(animation != null) animation.isEnabled = true; } else { if(animation != null) animation.isEnabled = false; } } } private System.Action onClick; public System.Action OnContinueClick { get { return onContinueClick; } set { onContinueClick = value; if (onContinueClick != null || onClick != null) { if(animation != null) animation.isEnabled = true; } else { if(animation != null) animation.isEnabled = false; } } } private System.Action onContinueClick; public override void AddButtonEvent() { longPressBtn = own.GetComponent(); if (longPressBtn == null) longPressBtn = own.AddComponent(); longPressBtn.onClick = () => OnClick?.Invoke(this); longPressBtn.longPress = () => OnContinueClick?.Invoke(this); if (own.transform.Find("Button") != null) { animation = own.transform.Find("Button").gameObject.GetComponent(); if (animation == null) animation = own.transform.Find("Button").gameObject.AddComponent(); animation.isEnabled = false; } base.AddButtonEvent(); } public override CTask AsyncInit(object[] uiData) { if (_rectTransform == null) { _rectTransform = GObjectPoolInterface.GetComponent(); } return base.AsyncInit(uiData); } public void SetBtnAnimation(bool isEnable) { if(animation) animation.isEnabled = isEnable; } public RectTransform Transform { get { return _rectTransform; } } public int index { get; set; } public virtual Vector2 GetSize() { return _rectTransform.sizeDelta; } public override void DormancyObj() { transform.GetComponent().anchorMax = Vector2.one * 0.5f; transform.GetComponent().anchorMin = Vector2.one * 0.5f; OnContinueClick = null; OnClick = null; base.DormancyObj(); } public void OnPointerClick() { OnClick?.Invoke(this); } public void OnPointerContinueClick() { OnContinueClick?.Invoke(this); } }