| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 | 
							- using System;
 
- using Fort23.Core;
 
- using Fort23.Mono;
 
- using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
 
- using UnityEngine;
 
- using UnityEngine.EventSystems;
 
- public class ItemWidgetBasic : UIComponent, IScorllListWidget
 
- {
 
-     public bool isUseDrag = false;
 
-     public bool isAddLongPressBtn = true;
 
-     public LongPressBtn longPressBtn;
 
-     public LongPressDragBtn longPressDragBtn;
 
-     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;
 
-             }
 
-         }
 
-     }
 
-     /// <summary>
 
-     /// 拖拽开始事件
 
-     /// </summary>
 
-     public Action<PointerEventData, ItemWidgetBasic> onDragStart;
 
-     /// <summary>
 
-     /// 拖拽进行中事件
 
-     /// </summary>
 
-     public Action<PointerEventData, ItemWidgetBasic> onDrag;
 
-     /// <summary>
 
-     /// 拖拽结束事件
 
-     /// </summary>
 
-     public Action<PointerEventData, ItemWidgetBasic> onDragEnd;
 
-     public Action<ItemWidgetBasic> onPointerEnter;
 
-     public Action<ItemWidgetBasic> onPointerExit;
 
-     private System.Action<ItemWidgetBasic> onContinueClick;
 
-     public override void AddButtonEvent()
 
-     {
 
-         base.AddButtonEvent();
 
-     }
 
-     private void OnPointerExit(PointerEventData obj)
 
-     {
 
-         onPointerExit?.Invoke(this);
 
-     }
 
-     private void OnPointerEnter(PointerEventData obj)
 
-     {
 
-         onPointerEnter?.Invoke(this);
 
-     }
 
-     private void OnDragStart(PointerEventData obj)
 
-     {
 
-         onDragStart?.Invoke(obj, this);
 
-     }
 
-     private void OnDrag(PointerEventData obj)
 
-     {
 
-         onDrag?.Invoke(obj, this);
 
-     }
 
-     private void OnDragEnd(PointerEventData obj)
 
-     {
 
-         onDragEnd?.Invoke(obj, this);
 
-     }
 
-     public override CTask<bool> AsyncInit(object[] uiData)
 
-     {
 
-         if (_rectTransform == null)
 
-         {
 
-             _rectTransform = GObjectPoolInterface.GetComponent<RectTransform>();
 
-         }
 
-         if (isAddLongPressBtn)
 
-         {
 
-             if (isUseDrag)
 
-             {
 
-                 longPressDragBtn = own.GetComponent<LongPressDragBtn>();
 
-                 if (longPressDragBtn == null)
 
-                     longPressDragBtn = own.AddComponent<LongPressDragBtn>();
 
-                 longPressDragBtn.onClick = () => OnClick?.Invoke(this);
 
-                 longPressDragBtn.longPress = () => OnContinueClick?.Invoke(this);
 
-                 longPressDragBtn.onDragStart = OnDragStart;
 
-                 longPressDragBtn.onDrag = OnDrag;
 
-                 longPressDragBtn.onDragEnd = OnDragEnd;
 
-                 longPressDragBtn.onPointerEnter = OnPointerEnter;
 
-                 longPressDragBtn.onPointerExit = OnPointerExit;
 
-             }
 
-             else
 
-             {
 
-                 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;
 
-         }
 
-         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);
 
-     }
 
- }
 
 
  |