2using System.Collections;
3using System.Collections.Generic;
63 public Func<T1, SortMode, int>
onSort;
100 val.SetActive(enable:
true);
101 val.transform.SetParent(
parent, worldPositionStays:
false);
107 uIButton.instantClick =
false;
117 orCreate.list =
list;
123 public void OnClick(
object obj, Component button)
139 public void OnRedraw(
object obj, Component c,
int index)
149 return onSort((T1)obj, mode);
179 return t.GetComponent<T2>();
201 void OnRedraw(
object obj, Component button,
int index);
273 public List<object>
items =
new List<object>();
276 public List<ButtonPair>
buttons =
new List<ButtonPair>();
295 public Dictionary<UIButton, UIList>
children =
new Dictionary<UIButton, UIList>();
299 "a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
300 "k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
301 "u",
"v",
"w",
"x",
"y",
"z"
348 foreach (
object item in collection)
396 UnityEngine.Object.DestroyImmediate(item2.
component.gameObject);
410 uIList.transform.SetSiblingIndex(button.transform.GetSiblingIndex() + 1);
412 uIList.parent =
this;
429 GetComponentInParent<ScrollRect>().RebuildLayout(recursive:
true);
439 GetComponentInParent<ScrollRect>().RebuildLayout(recursive:
true);
448 UnityEngine.Object.DestroyImmediate(base.gameObject);
453 this.RebuildLayout();
460 base.transform.
parent.RebuildLayout();
470 if (
this != activeList && (
bool)
group)
476 public virtual void Refresh(
bool highlightLast =
false)
491 if ((
bool)componentOf)
493 Component component = componentOf.transform.parent.GetComponent<
UIItem>();
494 if (component ==
null)
496 component = componentOf;
498 for (
int i = 0; i <
buttons.Count; i++)
500 if (
buttons[i].component == component)
511 UnityEngine.Object.DestroyImmediate(
group);
520 RectTransform rectTransform =
callbacks.GetMold().Rect();
521 rectTransform.sizeDelta =
new Vector2(rectTransform.sizeDelta.x, 34 +
heightFix);
548 GridLayoutGroup gridLayoutGroup =
layoutItems as GridLayoutGroup;
552 if ((
bool)gridLayoutGroup)
560 this.Rect().RebuildLayout();
561 this.Rect().ForceUpdateRectTransforms();
562 Canvas.ForceUpdateCanvases();
563 float y = RectTransformUtility.PixelAdjustRect(this.Rect(), GetComponentInParent<Canvas>()).size.y;
564 float y2 =
callbacks.GetMold().Rect().sizeDelta.y;
585 if (num >=
items.Count)
589 new GameObject().AddComponent<RectTransform>().SetParent(
layoutItems.transform, worldPositionStays:
false);
597 buttonPair.obj =
item;
598 buttonPair.component = comp;
615 uIButton.onClick.AddListener(delegate
635 if ((
bool)componentInChildren)
637 componentInChildren.onClick.Invoke();
641 SkinManager.tempSkin = tempSkin;
649 paginationTop.text1.text =
page + 1 +
" / " +
maxPage;
653 paginationBottom.text1.text =
page + 1 +
" / " +
maxPage;
689 public override void OnMove(
object o,
object select =
null)
696 public void Select(
int index = 0,
bool invoke =
false)
706 uIButton = (buttonPair.component as
UIItem)?.button1;
712 uIButton.onClick.Invoke();
714 if ((
bool)uIButton.
group)
725 public void Select(
object obj,
bool invoke =
false)
727 for (
int i = 0; i <
items.Count; i++)
737 public void Select<T>(Func<T, bool> func,
bool invoke =
false)
739 for (
int i = 0; i <
items.Count; i++)
741 if (func((T)
items[i]))
779 public void List(
bool refreshHighlight =
false)
812 GridLayoutGroup gridLayoutGroup =
layoutItems as GridLayoutGroup;
817 Vector2 vector2 = (
layoutItems.Rect().anchorMax =
new Vector2(0f, 1f));
818 Vector2 pivot = (rectTransform2.anchorMin = vector2);
819 rectTransform.pivot = pivot;
820 rectTransform.sizeDelta =
new Vector2(rectTransform.sizeDelta.x, (
float)
rows * gridLayoutGroup.cellSize.y);
833 T component =
moldItem.GetComponent<T>();
848 UnityEngine.Object.DestroyImmediate(
transNoItem.gameObject);
907 RectTransformUtility.ScreenPointToLocalPointInRectangle(
dragViewport, Input.mousePosition,
null, out var localPoint);
908 float y = localPoint.y;
909 float num = dragViewport.rect.height * 0.5f;
913 float num3 = Mathf.InverseLerp(0f - num +
dragEdgeSize, 0f - num, y);
918 float num4 = Mathf.InverseLerp(num -
dragEdgeSize, num, y);
923 float verticalNormalizedPosition =
dragScrollView.verticalNormalizedPosition;
924 dragScrollView.verticalNormalizedPosition = Mathf.Clamp01(verticalNormalizedPosition + num2 * Time.unscaledDeltaTime);
virtual void StopEventSystem(float duration=0.2f)
UIList.ICallback callbacks
static bool TryDespawn(Component c)
static Transform Spawn(string id, string path, Transform parent)
static SkinRootStatic CurrentSkin
static SkinRootStatic tempSkin
SkinRootStatic GetSkin(SkinType type)
void OnDragReorder(object obj, int a)
Action< T1, T2, int > onRedraw
Action< T1, T2 > onInstantiate
int OnSort(object obj, SortMode mode)
void OnList(SortMode mode)
Component GetComponent(Transform t)
Func< T1, SortMode, int > onSort
void OnClick(object obj, Component button)
Component Instantiate(object obj, Transform parent)
void SetList(UIList _list)
void OnRedraw(object obj, Component c, int index)
Action< SortMode > onList
bool CanDragReorder(object obj)
Func< T1, bool > canDragReorder
Action< T1, int > onDragReorder
void Select< T >(Func< T, bool > func, bool invoke=false)
UIList CreateChild(UIButton button)
List< ButtonPair > buttons
override void List(SortMode sort)
void AutoScrollWhileDragging()
void OnSelect(UIList activeList)
void List(bool refreshHighlight=false)
void UpdateItemDragHover(UIListDragItem drag)
int GetIndexOf(object item)
bool OnClickFolder(UIButton b, Action< UIList > onFold, bool refresh=true)
void BeginItemDrag(UIListDragItem drag)
GridLayoutGroup gridLayout
UIScrollView dragScrollView
void Select(object obj, bool invoke=false)
Dictionary< UIButton, UIList > children
void EndItemDrag(UIListDragItem drag)
void Select(int index=0, bool invoke=false)
void RebuildLayoutInParent()
bool onlyDirectChildrenButtonForGroup
override void OnMove(object o, object select=null)
void RemoveChild(UIButton button)
override void Add(object item)
static string[] strNumber
T GetPair< T >(object item)
void List(SortMode m, bool refreshHighlight=false)
ButtonPair GetPair(object item)
override void AddDynamic(object item)
void AddCollection(ICollection collection)
virtual void Refresh(bool highlightLast=false)
void ChangeSort(SortMode m)
RectTransform dragViewport
override void RemoveDynamic(object item)
override bool Contains(object item)
void Select(UIButton button, bool check=true)
virtual void Init(int index=0, UnityAction< int > action=null, bool directChildren=false)
void OnList(SortMode mode)
int OnSort(object obj, SortMode mode)
void SetList(UIList list)
void OnRedraw(object obj, Component button, int index)
Component GetComponent(Transform t)
void OnClick(object obj, Component button)
Component Instantiate(object obj, Transform parent)
void OnDragReorder(object obj, int a)
bool CanDragReorder(object obj)