/// <summary> /// 删除掉 /// </summary> /// <param name="index"></param> public void DeleteContent(int index) { if (isPlaying) { return; } ScollerMoveIterm frontItem = (ScollerMoveIterm)FindCellByIndex(index); frontItem.DismissCell(); ChangeBackCellPos(frontItem.CellNumber); isPlaying = true; animalState = 3; dismissCellIndex = index; // DeleteChild(index); }
public override void Update() { if (isPlaying) { playCount = 0; for (int i = 0; i < scolerIterms.Count; i++) { ScollerMoveIterm tmpItem = (ScollerMoveIterm)scolerIterms[i]; tmpItem.Update(); if (tmpItem.isPlaying) { playCount += 1; } } // Debug.Log("animal isPlaying==" + playCount); cellListen(); if (playCount == 0) { isPlaying = false; if (animalState == 3) { DeleteChild(dismissCellIndex); } else if (animalState == 4) { } } } }
private void ChangeBackCellPos(int cellNumber) { isPlaying = true; int tmpMax = scolerIterms.Count - 1 - cellNumber; for (int i = 1; i <= tmpMax; i++) { for (int j = 0; j < scolerIterms.Count; j++) { if (scolerIterms[j].CellNumber - cellNumber == i) { ScollerMoveIterm tmpItem = (ScollerMoveIterm)scolerIterms[j]; ScollerMoveIterm tmpFront = (ScollerMoveIterm)FindCellByNumber(tmpItem.CellNumber - 1); if (tmpFront != null) { tmpItem.CaculateMovePosition(tmpFront); // tmpItem.CaculateTargetPosition(currentOpeCell.hidlePanel.sizeDelta, currentOpeCell.isHide); } } } } }
/// <summary> /// 前面已经实例化了一个cell 在最后 现在修正 index number /// </summary> /// <param name="content"></param> public void AddCellToLastCellNumber(RectTransform content) { // ScollerItemBase tmpLastIndex = FindLastIndexCell(); ScollerItemBase tmpLastNumber = FindLastIndexCell(); int tmpIndex = tmpLastNumber.CellIndex; sbyte tmpNuber = tmpLastNumber.CellNumber; ScollerMoveIterm tmpAdd = AddChild(content.childCount - 1, content); for (int i = 0; i < scolerIterms.Count; i++) { ScollerItemBase tmpIterm = scolerIterms[i]; if (tmpIterm.CellIndex > tmpIndex) { tmpIterm.CellIndex += 1; } } tmpAdd.CellNumber = (sbyte)(tmpNuber + 1); tmpAdd.CellIndex = tmpIndex + 1; }
public void MoveToFrontPosition(ScollerMoveIterm frontItem) { Vector3 frontPos = frontItem.GetTargetPosition(); isPlaying = true; //UnityEngine.Debug.Log("CaculateMovePosition isPlaying" + cellIndex); animalState = 2; targetPos = frontPos; }
public void RefrushCellOrder(int insertIndex, ScollerMoveIterm inserIterm) { //先找到插入的位置 ScollerItemBase frontItem = FindCellByIndex(insertIndex); int tmpIndex = frontItem.CellIndex; sbyte tmpCellNub = frontItem.CellNumber; //更改其它 cell index for (int i = 0; i < scolerIterms.Count; i++) { ScollerItemBase tmpIterm = scolerIterms[i]; if (tmpIterm.CellIndex >= insertIndex) { tmpIterm.CellNumber += 1; tmpIterm.CellIndex += 1; } } // 将最后一个cell 移动要要插入的位置 inserIterm.MoveTo(frontItem); inserIterm.CellNumber = tmpCellNub; inserIterm.CellIndex = tmpIndex; ChangeBackCellPos(tmpCellNub); //for (int i = 0; i < scolerIterms.Count; i++) //{ // ScollerMoveIterm tmpIterm = (ScollerMoveIterm)scolerIterms[i]; // Debug.Log("tmpIterm.cell index===" + tmpIterm.CellIndex + "==cell number==" + tmpIterm.CellNumber); // if (tmpIterm.CellIndex > inserIterm.CellIndex) // { // ScollerItemBase tmpFront = FindCellByIndex(tmpIterm.CellIndex - 1); // tmpIterm.CaculateMovePosition(tmpFront); // } //} // inserIterm.CellLocalPosition = inserIterm.GetTargetPosition(); // inserIterm.cellIndex = frontItem.cellIndex + 1; }
public override void CellWillChange(ScollerItemBase from, ScollerItemBase to, byte direct) { base.CellWillChange(from, to, direct); ScollerMoveIterm tmpFront = (ScollerMoveIterm)from; bool hidden = tmpFront.HiddenNoAnimal(); //if (hidden) //{ // ChangeBackCellPos(tmpFront.cellNumber); //} }
public ScollerMoveIterm AddChild(int index, RectTransform content) { RectTransform tmpChild = content.GetChild(index).GetComponent <RectTransform>(); RectTransform sonPanel = tmpChild.Find("SonPanel").GetComponent <RectTransform>(); LeftTop(sonPanel); Button btn = tmpChild.Find("SonButton").GetComponent <Button>(); ScollerMoveIterm tmpIterm = new ScollerMoveIterm(sonPanel, tmpChild, btn, (sbyte)index, ButtonClick, direct); scolerIterms.Add(tmpIterm); return(tmpIterm); }
public void ReoderContentCell(RectTransform content, int inserIndex) { if (isPlaying) { return; } int index = content.childCount - 1; ScollerMoveIterm tmpItem = AddChild(index, content); // tmpItem.SettingIndex(lastItem.cellIndex+1); RefrushCellOrder(inserIndex, tmpItem); tmpItem.InsertCell(); isPlaying = true; animalState = 2; }