| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 | 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<ItemWidgetBasic> 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<ItemWidgetBasic> onClick;    public System.Action<ItemWidgetBasic> 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<ItemWidgetBasic> onContinueClick;    public override void AddButtonEvent()    {        longPressBtn = own.GetComponent<LongPressBtn>();        if (longPressBtn == null)            longPressBtn = own.AddComponent<LongPressBtn>();        longPressBtn.onClick = () => OnClick?.Invoke(this);        longPressBtn.longPress = () => OnContinueClick?.Invoke(this);        if (own.transform.Find("Button") != null)        {            animation = own.transform.Find("Button").gameObject.GetComponent<ButtonAnimation>();            if (animation == null)                animation = own.transform.Find("Button").gameObject.AddComponent<ButtonAnimation>();            animation.isEnabled = false;        }        base.AddButtonEvent();    }    public override CTask<bool> AsyncInit(object[] uiData)    {        if (_rectTransform == null)        {            _rectTransform = GObjectPoolInterface.GetComponent<RectTransform>();        }        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<RectTransform>().anchorMax = Vector2.one * 0.5f;        transform.GetComponent<RectTransform>().anchorMin = Vector2.one * 0.5f;        OnContinueClick = null;        OnClick = null;        base.DormancyObj();    }    public void OnPointerClick()    {        OnClick?.Invoke(this);    }    public void OnPointerContinueClick()    {        OnContinueClick?.Invoke(this);    }      }
 |