public bool AddSolt(Transform solt, int pos) { UIExGridPos.Get(solt.gameObject).mPos = pos; Vector3 scale = solt.localScale; solt.parent = myTransform; solt.localScale = scale; // if (!NGUITools.GetActive(solt.gameObject) && hideInactive) return false; float depth = -1; solt.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * mX, -cellHeight * mY, depth) : new Vector3(cellWidth * mY, -cellHeight * mX, depth); if (!Filter(solt)) { return(false); } if (++mX >= maxPerLine && maxPerLine > 0) { mX = 0; ++mY; } return(true); }
static public int SortDefault(Transform a, Transform b) { //----------------------- //吐槽:这个东西写在这是不合理的,此组件是作为公用组件设计,不应该在这里引用游戏具体的UI组件,而产生不合理的依赖关系. ItemUI aUI = a.gameObject.GetComponent <ItemUI>(); ItemUI bUI = b.gameObject.GetComponent <ItemUI>(); if (aUI != null && bUI != null) { return(aUI.pos.CompareTo(bUI.pos)); } //----------------------- UIExGridPos aPosComp = a.gameObject.GetComponent <UIExGridPos>(); UIExGridPos bPosComp = b.gameObject.GetComponent <UIExGridPos>(); if (aPosComp != null && bPosComp != null) { return(aPosComp.mPos.CompareTo(bPosComp.mPos)); } Debug.Log("确定是使用名字排序??"); return(string.Compare(a.name, b.name)); }