void Initial() { ScrollRect rect = transform.GetComponent <ScrollRect>(); RectTransform content = transform.GetChild(0).GetComponent <RectTransform>(); if (rect.vertical) { directer = ScollerDirect.Vertical; } else { directer = ScollerDirect.Horizontal; } content.localPosition = Vector3.zero; content.localScale = Vector3.one; content.localRotation = Quaternion.identity; sollerAnimal = new ScollerMoveAnimal(content, directer); looper = new ScollerLooper(rect, content, cellToatalCount, sollerAnimal, UpdateCell); looper.IsPlayingAnimal = IsPlayingAnimal; }
public ScollerMoveAnimal(RectTransform content, ScollerDirect direct) : base(direct) { scolerIterms = new List <ScollerItemBase>(); for (int i = 0; i < content.childCount; i++) { AddChild(i, content); } }
//private bool isPlaying; //public bool IsPlaying //{ // get // { // return isPlaying; // } // set // { // } //} public ScollerAnimal(RectTransform content, ScollerDirect tmpDirect) { scolerIterms = new List <ScollerItemBase>(); direct = tmpDirect; float tmpHeight = 0.0f; for (int i = 0; i < content.childCount; i++) { RectTransform tmpChild = content.GetChild(i).GetComponent <RectTransform>(); ScollerItemBase tmpItem = new ScollerItemBase(tmpChild, (sbyte)i, direct); // Debug.Log("tmpIterm-=="+ tmpIterm.cellPos+"==i=="+i); scolerIterms.Add(tmpItem); if (direct == ScollerDirect.Vertical) { tmpHeight += tmpChild.sizeDelta.y; } else { tmpHeight += tmpChild.sizeDelta.x; } } if (direct == ScollerDirect.Vertical) { if (tmpHeight < content.sizeDelta.y) { isPlaying = false; } else { isPlaying = true; } } else { if (tmpHeight < content.sizeDelta.x) { isPlaying = false; } else { isPlaying = true; } } }
public ScollerItemBase(RectTransform tmpRect, sbyte index, ScollerDirect tmpDirect) { this.cellWidth = tmpRect.sizeDelta.x; this.cellHeight = tmpRect.sizeDelta.y; this.cellTransform = tmpRect; this.cellIndex = this.cellNumber = index; Direct = tmpDirect; InitialSon(tmpRect); targetPos = cellTransform.localPosition; }
/// <summary> /// 初始化必备条件 /// </summary> /// <param name="cellNumber"> 单元格的个数</param> /// <param name="direct"> 1 表示 竖直 2 表示横向</param> /// <param name="tmpObj"></param> public void InitialChild(int cellNumber, int tmpDirect, Object tmpObj) { cellCount = cellNumber; scollerTrans = gameObject.GetComponent <RectTransform>(); LeftTop(scollerTrans); if (tmpDirect == 1) { direct = ScollerDirect.Vertical; } else { direct = ScollerDirect.Horizontal; } AutoBuilder(tmpObj); }
public ScollerAnimal(ScollerDirect tmpDirect) { direct = tmpDirect; }
public ScollerMoveIterm(RectTransform sonPanel, RectTransform itemRect, Button button, sbyte index, ClickOn click, ScollerDirect tmpDirect) : base(itemRect, index, tmpDirect) { isHide = true; hidlePanel = sonPanel; //UnityEngine.Debug.Log("ScollerMoveIterm direct ==" + direct); hidlePanel.localScale = new Vector2(1, 0); parentHeight = itemRect.rect.height; parentWidth = itemRect.rect.width; hidePanelHeigth = hidlePanel.rect.height; hidePanelWidth = hidlePanel.rect.width; btnClick = new ClickOn(click); // Button btn = itemRect.GetComponentInChildren<Button>(); button.onClick.AddListener(BtnClick); // targetPos = cellTransform.localPosition; }
public ScollerLooper(ScrollRect scol, RectTransform cont, int cout, ScollerAnimal animal, UpdateCellDelegate update) { scoller = scol; content = cont; updateCell = update; totalCellCount = cout; // Debug.Log("totalCellCount=="+ totalCellCount); contentLocalPosition = cont.localPosition; if (scol.horizontal) { Direct = ScollerDirect.Horizontal; } else { Direct = ScollerDirect.Vertical; // connerTwo.y += content.sizeDelta.y; } if (animal != null) { scollerAnimal = animal; scolerIterms = animal.scolerIterms; } else { scollerAnimal = new ScollerAnimal(content, direct); scolerIterms = scollerAnimal.scolerIterms; } // cellCount = scolerIterms.Count; RefushCellCount(); scollerAnimal.cellListen = new ScollerAnimal.CellChangeListen(UpdateContent); // ScollerItemBase tmpItem2 = FindCell(1); conner = cont.TransformPoint(Vector3.zero); //connerTwo = cont.TransformPoint(Vector3.zero); // scollerAnimal.Direct = Direct; Vector3 tmpConor = cont.InverseTransformPoint(conner); scoller.onValueChanged.AddListener(ScolerValueChange); }