public void Setup(ObjectListController _controller, float _delay, SortStats _stats, int _direction) { delay = _delay; controller = _controller; stats = _stats; stats.Size = controller.GetSize(); direction = (SortDirection)_direction; }
// Start is called before the first frame update void Start() { sortType = 0; controller = ScriptableObject.CreateInstance <ObjectListController>(); sortHandler = gameObject.AddComponent <SortHandler>(); stats = new SortStats(statsSize, statsAccesses, statsCompares, statsSwaps, statsDelay, controller.GetSize(), delay); OnSetup(); OnDelayUpdate(1); }
/// <summary> /// 设置Content位置 /// </summary> private void SetContentPos() { ObjectListController listController = ObjectListController.Instance; if (listController) { Transform contentTemp = listController.content; RectTransform rect = contentTemp.GetComponent <RectTransform>(); RectTransform rectParent = contentTemp.parent.GetComponent <RectTransform>(); if (rect.rect.size.y <= rectParent.rect.size.y) { rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, 0); } } }
public IEnumerator DoSort(ObjectListController _controller, int type, float delay, SortStats stats, int direction) { if (state == SortState.Sorting) { yield break; } stats.Init(); sortAlgorithm = sortFactory.GetSortAlgorithm(type); sortAlgorithm.Setup(_controller, delay, stats, direction); state = SortState.Sorting; yield return(StartCoroutine(sortAlgorithm.DoSort())); sortAlgorithm.DeselectAll(); if (state == SortState.Sorting) { Destroy(sortAlgorithm); } state = SortState.Idle; }
void Awake() { Instance = this; }