/// <summary> /// Advance toward the target position. /// </summary> void Update() { float delta = UpdateRealTimeDelta(); if (mThreshold == 0f) { mThreshold = (target - mTrans.localPosition).magnitude * 0.005f; mThreshold = Mathf.Max(mThreshold, 0.00001f); } bool trigger = false; Vector3 before = mTrans.localPosition; Vector3 after = NGUIMath.SpringLerp(mTrans.localPosition, target, strength, delta); if (mDrag.scale.x == 0) { after.x = before.x; } if (mDrag.scale.y == 0) { after.y = before.y; } if (mThreshold >= Vector3.Magnitude(after - target)) { after = target; enabled = false; trigger = true; } mTrans.localPosition = after; Vector3 offset = after - before; Vector4 cr = mPanel.clipRange; if (mDrag.scale.x != 0) { cr.x -= offset.x; } if (mDrag.scale.y != 0) { cr.y -= offset.y; } mPanel.clipRange = cr; if (mDrag != null) { mDrag.UpdateScrollbars(false); } if (trigger && onFinished != null) { onFinished(); } }
private void Update() { float deltaTime = UpdateRealTimeDelta(); if (mThreshold == 0f) { mThreshold = (target - mTrans.localPosition).magnitude * 0.005f; } bool flag = false; Vector3 localPosition = mTrans.localPosition; Vector3 vector = NGUIMath.SpringLerp(mTrans.localPosition, target, strength, deltaTime); if (mThreshold >= Vector3.Magnitude(vector - target)) { vector = target; base.enabled = false; flag = true; } mTrans.localPosition = vector; Vector3 vector2 = vector - localPosition; Vector4 clipRange = mPanel.clipRange; clipRange.x -= vector2.x; clipRange.y -= vector2.y; mPanel.clipRange = clipRange; if (mDrag != null) { mDrag.UpdateScrollbars(recalculateBounds: false); } if (flag && onFinished != null) { onFinished(); } }
/// <summary> /// Reposition all elements in the grid. /// </summary> public void Reposition() { Transform myTrans = transform; List <Transform> children = new List <Transform>(); for (int i = 0; i < myTrans.childCount; ++i) { Transform child = myTrans.GetChild(i); if (!hideInactive || child.gameObject.active) { children.Add(child); } } if (sorted) { children.Sort(SortByName); } if (children.Count > 0) { RepositionVariableSize(children); } if (mPanel != null && mDrag == null) { mPanel.ConstrainTargetToBounds(myTrans, true); } if (mDrag != null) { mDrag.UpdateScrollbars(true); } }
public void Reposition() { if (mStarted) { var target = transform; mChildren.Clear(); var children = this.children; if (children.Count > 0) { RepositionVariableSize(children); } if (mDrag != null) { mDrag.UpdateScrollbars(true); mDrag.RestrictWithinBounds(true); } else if (mPanel != null) { mPanel.ConstrainTargetToBounds(target, true); } onReposition?.Invoke(); } else { repositionNow = true; } }
public void Reposition() { if (mStarted) { Transform transform = base.transform; mChildren.Clear(); List <Transform> children = this.children; if (children.Count > 0) { RepositionVariableSize(children); } if (mDrag != null) { mDrag.UpdateScrollbars(recalculateBounds: true); mDrag.RestrictWithinBounds(instant: true); } else if (mPanel != null) { mPanel.ConstrainTargetToBounds(transform, immediate: true); } if (onReposition != null) { onReposition(); } } else { repositionNow = true; } }
/// <summary> /// Advance toward the target position. /// </summary> void Update() { float delta = UpdateRealTimeDelta(); if (mThreshold == 0f) { mThreshold = (target - mTrans.localPosition).magnitude * 0.005f; } Vector3 before = mTrans.localPosition; mTrans.localPosition = NGUIMath.SpringLerp(mTrans.localPosition, target, strength, delta); Vector3 offset = mTrans.localPosition - before; Vector4 cr = mPanel.clipRange; cr.x -= offset.x; cr.y -= offset.y; mPanel.clipRange = cr; if (mDrag != null) { mDrag.UpdateScrollbars(false, true); } if (mThreshold >= (target - mTrans.localPosition).magnitude) { enabled = false; } }
public void UpdateList(int count, DSetContent setContent, DClearContent clearContent) { if (count > m_Items.Count) { for (int i = 0; i < m_Items.Count; i++) { Transform trans = m_Items[i].transform; trans.localPosition = new Vector3(0, -i * cellHeight, 0); if (setContent != null) { setContent(i, m_Items[i]); } } for (int i = m_Items.Count; i < count; i++) { GameObject go = CreateGo(); go.transform.localPosition = new Vector3(0, -i * cellHeight, 0); if (setContent != null) { setContent(i, go); } m_Items.Add(go); } } else { for (int i = 0; i < count; i++) { Transform trans = m_Items[i].transform; trans.localPosition = new Vector3(0, -i * cellHeight, 0); if (setContent != null) { setContent(i, m_Items[i]); } } for (int i = m_Items.Count - 1; i >= count; i--) { if (clearContent != null) { clearContent(m_Items[i]); } DestroyGo(m_Items[i]); } m_Items.RemoveRange(count, m_Items.Count - count); } repositionPosNow = true; repositionVisibleNow = true; UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } }
/// <summary> /// Recalculate the position of all elements within the table, sorting them alphabetically if necessary. /// </summary> public void Reposition() { if (mStarted) { Transform myTrans = transform; mChildren.Clear(); List <Transform> ch = children; if (ch.Count > 0) { RepositionVariableSize(ch); } if (mDrag != null) { mDrag.UpdateScrollbars(true); mDrag.RestrictWithinBounds(true); } else if (mPanel != null) { mPanel.ConstrainTargetToBounds(myTrans, true); } if (onReposition != null) { onReposition(); } } else { repositionNow = true; } }
public void UpdateList(int count, IListReceiver receiver) { if (receiver == null) { Debug.LogError("The receiver is null"); return; } if (count > m_Items.Count) { for (int i = 0; i < m_Items.Count; i++) { Transform trans = m_Items[i].transform; trans.localPosition = new Vector3(0, -i * cellHeight, 0); receiver.SetContent(i, m_Items[i]); } for (int i = m_Items.Count; i < count; i++) { GameObject go = CreateGo(); go.transform.localPosition = new Vector3(0, -i * cellHeight, 0); receiver.SetContent(i, go); m_Items.Add(go); } } else { for (int i = 0; i < count; i++) { Transform trans = m_Items[i].transform; trans.localPosition = new Vector3(0, -i * cellHeight, 0); receiver.SetContent(i, m_Items[i]); } for (int i = m_Items.Count - 1; i >= count; i--) { receiver.ClearContent(m_Items[i]); DestroyGo(m_Items[i]); } m_Items.RemoveRange(count, m_Items.Count - count); } repositionPosNow = true; repositionVisibleNow = true; UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } }
public void SetPosition(Vector3 newPos) { try{ // 调试时,进入地图后,拖动时,发生空指针错误 contents.parent.localPosition = newPos; }catch { Debug.Log(" contents.parent is null"); } Vector4 panelClip = myPanel.clipRange; panelClip.x = -cachedTransform.localPosition.x; panelClip.y = -cachedTransform.localPosition.y; myPanel.clipRange = panelClip; myDragPanel.UpdateScrollbars(true); myDragPanel.RestrictWithinBounds(true); }
public static Bounds FocusClipPanelOnPosition(Vector3 worldPosition, UIPanel clipPanel, UIDraggablePanel dragPanel, float normalizedRange, float minBrowserPosition) { Bounds browserBounds; if (!IsClipPanelPositionVisible(worldPosition, clipPanel, normalizedRange, out browserBounds)) { Vector3 targetPosition = browserBounds.center; targetPosition.y = targetPosition.y + (browserBounds.size.y / 2); targetPosition = clipPanel.transform.InverseTransformPoint(browserBounds.center); //move the background by the amount of space it would take to reach the object Vector3 relativeDifference = targetPosition - clipPanel.transform.InverseTransformPoint(worldPosition); relativeDifference.z = 0f; relativeDifference.x = 0f; //should we really do this...? dragPanel.MoveRelative(relativeDifference, true, minBrowserPosition); dragPanel.UpdateScrollbars(true, true); //Debug.Log("world position " + worldPosition.ToString() + " was NOT visible in clip panel " + clipPanel.name + ", moving " + relativeDifference.y.ToString()); } return(browserBounds); }
/// <summary> /// Advance toward the target position. /// </summary> protected virtual void AdvanceTowardsPosition() { float delta = RealTime.deltaTime; if (mThreshold == 0f) { mThreshold = (target - mTrans.localPosition).magnitude * 0.005f; mThreshold = Mathf.Max(mThreshold, 0.00001f); } bool trigger = false; Vector3 before = mTrans.localPosition; Vector3 after = NGUIMath.SpringLerp(mTrans.localPosition, target, strength, delta); if (mThreshold >= Vector3.Magnitude(after - target)) { after = target; enabled = false; trigger = true; } mTrans.localPosition = after; Vector3 offset = after - before; Vector4 cr = mPanel.clipRange; cr.x -= offset.x; cr.y -= offset.y; mPanel.clipRange = cr; if (mDrag != null) { mDrag.UpdateScrollbars(false); } if (trigger && onFinished != null) { onFinished(); } }
private void Update() { var deltaTime = UpdateRealTimeDelta(); if (mThreshold == 0f) { var vector = this.target - mTrans.localPosition; mThreshold = vector.magnitude * 0.005f; } var flag = false; var localPosition = mTrans.localPosition; var target = NGUIMath.SpringLerp(mTrans.localPosition, this.target, strength, deltaTime); if (mThreshold >= Vector3.Magnitude(target - this.target)) { target = this.target; enabled = false; flag = true; } mTrans.localPosition = target; var vector4 = target - localPosition; var clipRange = mPanel.clipRange; clipRange.x -= vector4.x; clipRange.y -= vector4.y; mPanel.clipRange = clipRange; if (mDrag != null) { mDrag.UpdateScrollbars(false); } if (flag) { onFinished?.Invoke(); } }
private void SelectEntry(UnlockContentEntry p_entry) { if (m_selectedEntry != null) { m_selectedEntry.SetSelected(false); } m_selectedEntry = p_entry; m_selectedEntry.SetSelected(true); m_contentTitle.text = LocaManager.GetText(m_selectedEntry.StaticData.NameKey); m_contentInfo.text = LocaManager.GetText(m_selectedEntry.StaticData.InfoTextKey); Boolean flag = m_selectedEntry.StaticData.IsBuyable && !LegacyLogic.Instance.ServiceWrapper.IsPrivilegeAvailable(m_selectedEntry.StaticData.PrivilegeId); Texture texture = Helper.ResourcesLoad <Texture>("UnlockContent/" + m_selectedEntry.StaticData.Image); if (m_contentImage.mainTexture != texture) { Texture mainTexture = m_contentImage.mainTexture; m_contentImage.mainTexture = texture; if (mainTexture != null) { mainTexture.UnloadAsset(); } } m_dragPanel.UpdateScrollbars(true); }
/// <summary> /// Recalculate the position of all elements within the grid, sorting them alphabetically if necessary. /// </summary> public void Reposition() { if (!mStarted) { repositionNow = true; return; } int x = 0; int y = 0; if (ReverseList) { for (int i = gridObjects.Count; i-- > 0;) { if (!NGUITools.GetActive(gridObjects[i].gameObject) && hideInactive) { continue; } float depth = gridObjects[i].localPosition.z; gridObjects[i].localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x, depth); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } else { foreach (Transform t in gridObjects) { if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x, depth); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } }
/// <summary> /// 控制从左到右还是从右到左 /// 从上到下还是从下到上 /// </summary> /// <param name="revertFlag">If set to <c>true</c> revert flag.</param> public override void Reposition() { if (!mStarted) { repositionNow = true; return; } Transform myTrans = transform; int x = 0; int y = 0; int factor = Revert?-1:1; if (sorted) { List <Transform> list = new List <Transform>(); for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (t && (!hideInactive || NGUITools.GetActive(t.gameObject))) { list.Add(t); } } //list.Sort(SortByName); for (int i = 0, imax = list.Count; i < imax; ++i) { Transform t = list[i]; if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x * factor, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x * factor, depth); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } else { for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x * factor, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x * factor, depth); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } }
public void Reposition() { if (!this.mStarted) { this.repositionNow = true; } else { Transform transform = base.transform; int num = 0; int num2 = 0; if (this.sorted) { List <Transform> list = new List <Transform>(); for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if ((child != null) && (!this.hideInactive || NGUITools.GetActive(child.gameObject))) { list.Add(child); } } list.Sort(new Comparison <Transform>(UIGrid.SortByName)); int num4 = 0; int count = list.Count; while (num4 < count) { Transform transform3 = list[num4]; if (NGUITools.GetActive(transform3.gameObject) || !this.hideInactive) { float z = transform3.localPosition.z; transform3.localPosition = (this.arrangement != Arrangement.Horizontal) ? new Vector3(this.cellWidth * num2, -this.cellHeight * num, z) : new Vector3(this.cellWidth * num, -this.cellHeight * num2, z); if ((++num >= this.maxPerLine) && (this.maxPerLine > 0)) { num = 0; num2++; } } num4++; } } else { for (int j = 0; j < transform.childCount; j++) { Transform transform4 = transform.GetChild(j); if (NGUITools.GetActive(transform4.gameObject) || !this.hideInactive) { float num8 = transform4.localPosition.z; transform4.localPosition = (this.arrangement != Arrangement.Horizontal) ? new Vector3(this.cellWidth * num2, -this.cellHeight * num, num8) : new Vector3(this.cellWidth * num, -this.cellHeight * num2, num8); if ((++num >= this.maxPerLine) && (this.maxPerLine > 0)) { num = 0; num2++; } } } } UIDraggablePanel panel = NGUITools.FindInParents <UIDraggablePanel>(base.gameObject); if (panel != null) { panel.UpdateScrollbars(true); } } }
private void Start() { // Create Ranking Draggable Panel Transform grid_trans = transform.FindChild("DraggablePanel/Grid"); //Transform grid_trans = transform.FindChild("Grid"); if( grid_trans != null ){ for(int i = 0; i < RANKING_LIST_NUM; ++i){ GameObject panel = NGUITools.AddChild(grid_trans.gameObject, m_RankingPanel_Prefab); if( panel != null ){ panel.name = "Item_" + i.ToString("D2"); UIRankingPanel ranking_panel = panel.GetComponent<UIRankingPanel>(); m_RankingPanelList[i] = ranking_panel; } } Transform draggable_panel_trans = transform.FindChild("DraggablePanel"); if( draggable_panel_trans != null ){ m_DraggablePanel = draggable_panel_trans.gameObject.GetComponent<UIDraggablePanel>(); if( m_DraggablePanel != null ){ m_OriginalClippingCenter_y = m_DraggablePanel.panel.clipRange.y; m_OriginalLocalPosition_y = m_DraggablePanel.transform.localPosition.y; if( (m_DraggablePanel.verticalScrollBar != null) && (m_DraggablePanel.horizontalScrollBar != null) ){ m_DraggablePanel.UpdateScrollbars(true); m_DraggablePanel.verticalScrollBar.scrollValue = 0.0f; } } } m_UIGrid = grid_trans.gameObject.GetComponent<UIGrid>(); if( m_UIGrid != null ){ m_UIGrid.Reposition(); } foreach(UIRankingPanel panel in m_RankingPanelList){ panel.gameObject.isStatic = true; NGUITools.SetActive(panel.gameObject, false); } } Transform panel_middle = transform.FindChild("Panel Middle/Icon"); if( panel_middle != null ){ for(int i = 0; i < (int)SaveData.TRACK_RECORD.MAX_NUM; ++i ){ m_MyTrackRecords[i] = panel_middle.FindChild("Sprite (rank_" + i.ToString("D2") + ")").gameObject; if( m_MyTrackRecords[i] != null ){ NGUITools.SetActive( m_MyTrackRecords[i], false); } } } }
public void Reposition() { Transform myTrans = transform; int x = 0; int y = 0; if (sorted) { List <Transform> list = new List <Transform>(); for (int i = 0; i < myTrans.childCount; ++i) { list.Add(myTrans.GetChild(i)); } list.Sort(SortByName); for (int i = 0, imax = list.Count; i < imax; ++i) { Transform t = list[i]; if (!t.gameObject.active && hideInactive) { continue; } t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, 0f) : new Vector3(cellWidth * y, -cellHeight * x, 0f); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } else { for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (!t.gameObject.active && hideInactive) { continue; } t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, 0f) : new Vector3(cellWidth * y, -cellHeight * x, 0f); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } }
/// <summary> /// Recalculate the position of all elements within the grid, sorting them alphabetically if necessary. /// </summary> public void Reposition() { if (!mStarted) { repositionNow = true; return; } Transform myTrans = transform; int x = 0; int y = 0; if (sorted) { List <Transform> list = new List <Transform>(); for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (t && (!hideInactive || NGUITools.GetActive(t.gameObject))) { list.Add(t); } } list.Sort(SortByName); for (int i = 0, imax = list.Count; i < imax; ++i) { Transform t = list[i]; if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x, depth); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } else { for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (!t.gameObject.activeSelf) { continue; } if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } //根据业务需求,暂时只做 /* * if (bUseTween && i < nTweenItemNum && arrangement == Arrangement.Vertical) * { * float depth = t.localPosition.z; * int nItemWidth = nTweenWidth * (i + 1); * // if(t.transform.GetComponent<UITweener>() != null) * // { * // Destroy(t.transform.GetComponent<UITweener>()) * // } * * // UITweener uiTweener = t.transform.gameObject.AddComponent<UITweener>(); * // uiTweener.style = UITweener.Style.Once; * // uiTweener * t.localPosition = new Vector3(cellWidth * y, -cellHeight * x, depth); * Vector3 vec3Postion = new Vector3(t.position.x, t.position.y, t.position.z); * //Vector3 vec3Postion = new Vector3(0, 0, t.position.z); * t.localPosition = new Vector3(cellWidth * y + nItemWidth, -cellHeight * x, depth); * * Hashtable hash = new Hashtable(); * hash.Add("time", fTweenTime); * hash.Add("position", vec3Postion); * hash.Add("easeType", iTween.EaseType.linear); * * * //iTween.MoveTo(t.gameObject, vec3Postion, 0.5f*(i+1)); * iTween.MoveTo(t.gameObject, hash); * // iTween itween = t.GetComponent<iTween>(); * // if (itween != null) * // { * // itween.easeType = iTween.EaseType.linear; * // } * //Debug.Log(-cellHeight * x); * //t.gameObject.AddComponent<iTween>(); * } * else * { */ float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x, depth); // int nItemWidth = nTweenWidth * (i + 1); // Debug.Log(cellWidth * y + nItemWidth); //} if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } }
/// <summary> /// Recalculate the position of all elements within the grid, sorting them alphabetically if necessary. /// </summary> public void Reposition(bool isByNum = false) // 使用数字顺序时需要传参数true,其余情况下仍然走false的字典序 / { if (!mStarted) { repositionNow = true; return; } Transform myTrans = transform; int x = 0; int y = 0; int maxX = 0; int maxY = 0; if (sorted) { List <Transform> list = new List <Transform>(); for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (t && (!hideInactive || NGUITools.GetActive(t.gameObject))) { list.Add(t); } } if (isByNum) { list.Sort(SortByNum); } else { list.Sort(SortByName); } for (int i = 0, imax = list.Count; i < imax; ++i) { Transform t = list[i]; if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x, depth); maxX = Mathf.Max(maxX, x); maxY = Mathf.Max(maxY, y); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } else { for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x, depth); maxX = Mathf.Max(maxX, x); maxY = Mathf.Max(maxY, y); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } // Apply the origin offset if (pivot != UIWidget.Pivot.TopLeft) { Vector2 po = NGUIMath.GetPivotOffset(pivot); float fx, fy; if (arrangement == Arrangement.Horizontal) { fx = Mathf.Lerp(0f, maxX * cellWidth, po.x); fy = Mathf.Lerp(-maxY * cellHeight, 0f, po.y); } else { fx = Mathf.Lerp(0f, maxY * cellWidth, po.x); fy = Mathf.Lerp(-maxX * cellHeight, 0f, po.y); } for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); SpringPosition sp = t.GetComponent <SpringPosition>(); if (sp != null) { sp.target.x -= fx; sp.target.y -= fy; } else { Vector3 pos = t.localPosition; pos.x -= fx; pos.y -= fy; t.localPosition = pos; } } } UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } if (onReposition != null) { onReposition(); } }
public void Run() { //sdUICharacter.Instance.HideMask(); needShowPoint = false; sdUICharacter.Instance.MsgClickCancel(); int num = 0; string[] param = opParam.ToString().Split(';'); if ((opType & (int)GuideOperationType.None) > 0) { } if ((opType & (int)GuideOperationType.ShowArrow) > 0) { if (param.Length > num) { string objName = param[num]; GameObject obj = GameObject.Find(objName); sdUICharacter.Instance.ShowArrow(obj); ++num; } } if ((opType & (int)GuideOperationType.ShowPoint) > 0) { if (param.Length > num) { ShowPoint(param[num]); ++num; } } if ((opType & (int)GuideOperationType.ShowWord) > 0) { if (param.Length > num) { string word = param[num]; if (sdGameLevel.instance == null) { return; } sdMovieDialogue dlg = sdGameLevel.instance.gameObject.GetComponent <sdMovieDialogue>(); if (dlg == null) { dlg = sdGameLevel.instance.gameObject.AddComponent <sdMovieDialogue>(); } if (dlg != null) { dlg.SetMovieInfo(int.Parse(word), true, true, Vector3.one, Vector3.zero); sdGameLevel.instance.guideDialogueEnd += OnFinish; ++num; } } } if ((opType & (int)GuideOperationType.ShowEffect) > 0) { if (param.Length > num) { string word = param[num]; string[] wordlist = word.Split('|'); GameObject item = GameObject.Find(wordlist[0]); ResLoadParams p = new ResLoadParams(); p.info = "effect"; p.userdata0 = item; sdResourceMgr.Instance.LoadResource(wordlist[1], LoadEffect, p); ++num; } } if ((opType & (int)GuideOperationType.HideObj) > 0) { if (param.Length > num) { string objName = param[num]; GameObject obj = GameObject.Find(objName); if (obj != null) { obj.SetActive(false); if (!sdGuideMgr.Instance.hideList.Contains(objName)) { sdGuideMgr.Instance.hideList.Add(objName, obj); } else { sdGuideMgr.Instance.hideList[objName] = obj; } } ++num; } } if ((opType & (int)GuideOperationType.ShowObj) > 0) { if (param.Length > num) { string objName = param[num]; if (sdGuideMgr.Instance.hideList[objName] != null) { GameObject obj = sdGuideMgr.Instance.hideList[objName] as GameObject; obj.SetActive(true); } ++num; } } if ((opType & (int)GuideOperationType.PointEquip) > 0) { if (param.Length > num) { sdUICharacter.Instance.tipCanEquip = true; if (sdGameLevel.instance == null || sdGameLevel.instance.mainChar == null) { return; } string tid = ""; string[] wordlist = param[num].Split('|'); if (wordlist.Length == 1) { Hashtable needEquip = new Hashtable(); Hashtable itemTable = sdGameItemMgr.Instance.GetAllItem((int)PanelType.Panel_Bag, -1); foreach (DictionaryEntry itemInfo in itemTable) { sdGameItem item = itemInfo.Value as sdGameItem; if (item.equipPos < 0) { continue; } if (!item.CanEquip(sdGameLevel.instance.mainChar)) { continue; } if (needEquip.ContainsKey(item.equipPos)) { sdGameItem maxItem = needEquip[item.equipPos] as sdGameItem; int maxScore = sdConfDataMgr.Instance().GetItemScore(maxItem.instanceID); int curScore = sdConfDataMgr.Instance().GetItemScore(item.instanceID); if (curScore > maxScore) { needEquip[item.equipPos] = item; } } else { needEquip.Add(item.equipPos, item); } } foreach (DictionaryEntry itemInfo in needEquip) { sdGameItem item = itemInfo.Value as sdGameItem; sdGameItem compareItem = sdGameItemMgr.Instance.getEquipItemByPos(item.equipPos); if (compareItem == null) { tid = item.templateID.ToString(); break; } int score = sdConfDataMgr.Instance().GetItemScore(item.instanceID); int compareScore = sdConfDataMgr.Instance().GetItemScore(compareItem.instanceID); if (score > compareScore) { tid = item.templateID.ToString(); break; } } } else { int job = int.Parse(sdGameLevel.instance.mainChar.GetProperty()["Job"].ToString()); if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Warrior) { tid = wordlist[0]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Magic) { tid = wordlist[1]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Rogue) { tid = wordlist[2]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Minister) { tid = wordlist[3]; } } Hashtable info = sdConfDataMgr.Instance().GetItemById(tid); sdSlotMgr.Instance.GotoEquip(int.Parse(info["Character"].ToString())); Hashtable table = sdSlotMgr.Instance.GetIconList(PanelType.Panel_Bag); foreach (DictionaryEntry item in table) { sdSlotIcon icon = item.Value as sdSlotIcon; if (icon.tempId == tid) { icon.gameObject.name = "guide_item"; ShowPoint(icon.gameObject.name + "|1"); } } ++num; } } if ((opType & (int)GuideOperationType.JumpMap) > 0) { Debug.Log(string.Format("guide:{0}", id)); sdUICharacter.JumpToWorldMap(); } if ((opType & (int)GuideOperationType.SmallWord) > 0) { if (param.Length > num) { string word = param[num]; if (sdGameLevel.instance == null) { return; } sdGuideDialogue dlg = sdGameLevel.instance.gameObject.GetComponent <sdGuideDialogue>(); if (dlg == null) { dlg = sdGameLevel.instance.gameObject.AddComponent <sdGuideDialogue>(); } if (dlg != null) { string[] wordlist = word.Split('|'); Vector3 pos = Vector3.zero; if (wordlist.Length >= 3) { string posStr = wordlist[2]; string[] posList = posStr.Split('@'); pos.y = int.Parse(posList[1]); pos.x = int.Parse(posList[0]); } dlg.SetMovieInfo(int.Parse(wordlist[1]), new Vector3(1f, 1f, 1f), pos); //sdGameLevel.instance.mainCamera.GetComponent<sdGameCamera>().zoomEnd += OnFinish; ++num; } } } if ((opType & (int)GuideOperationType.Spec) > 0) { if (param.Length > num) { string tid = param[num]; if (tid == "2") { EventDelegate finish = new EventDelegate(OnFinish); sdUICharacter.Instance.ShowGuideRoll(finish); } else if (tid == "3") { if (sdGameLevel.instance != null) { sdGameLevel.instance.AutoMode = true; sdGameLevel.instance.FullAutoMode = false; } } else if (tid == "4") { sdUICharacter.Instance.tipCanEquip = false; } ++num; } } if ((opType & (int)GuideOperationType.OpenFrame) > 0) { GameObject panel = GameObject.Find("Sys1"); if (panel != null) { GameObject btn = GameObject.Find("Btn_Push"); UISprite sp = btn.transform.FindChild("Background").GetComponent <UISprite>(); sdRoleWndButton.sysPanelPos = panel.transform.localPosition.x; panel.transform.localPosition = new Vector3(640.0f - 120.0f * panel.transform.localScale.x, panel.transform.localPosition.y, panel.transform.localPosition.z); sp.spriteName = "btn_c"; } } if ((opType & (int)GuideOperationType.PointItemUp) > 0) { if (param.Length > num) { if (sdGameLevel.instance == null || sdGameLevel.instance.mainChar == null) { return; } sdUICharacter.Instance.tipCanEquip = true; string tid = ""; string[] wordlist = param[num].Split('|'); int job = int.Parse(sdGameLevel.instance.mainChar.GetProperty()["Job"].ToString()); if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Warrior) { tid = wordlist[0]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Magic) { tid = wordlist[1]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Rogue) { tid = wordlist[2]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Minister) { tid = wordlist[3]; } Hashtable iconList = sdSlotMgr.Instance.GetIconList(PanelType.Panel_ItemSelect); foreach (DictionaryEntry item in iconList) { sdSlotIcon icon = item.Value as sdSlotIcon; if (icon.tempId == tid) { UIDraggablePanel panel = icon.GetComponentInParent <UIDraggablePanel>(); Vector3 pos = Vector3.zero; pos.y = -icon.transform.localPosition.y; panel.MoveRelative(pos); panel.UpdateScrollbars(true); icon.gameObject.name = "guide_item"; ShowPoint(icon.gameObject.name + "|1"); break; } } ++num; } } if ((opType & (int)GuideOperationType.LockTown) > 0) { sdUICharacter.Instance.bLockTown = true; } WaitForEvetnt(); }
public void Reposition() { if (!mStarted) { repositionNow = true; return; } Transform transform = this.transform; Int32 num = 0; Int32 num2 = 0; if (sorted) { List <Transform> list = new List <Transform>(); for (Int32 i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (child && (!hideInactive || NGUITools.GetActive(child.gameObject))) { list.Add(child); } } list.Sort(new Comparison <Transform>(SortByName)); Int32 j = 0; Int32 count = list.Count; while (j < count) { Transform transform2 = list[j]; if (NGUITools.GetActive(transform2.gameObject) || !hideInactive) { Single z = transform2.localPosition.z; transform2.localPosition = ((arrangement != Arrangement.Horizontal) ? new Vector3(cellWidth * num2, -cellHeight * num, z) : new Vector3(cellWidth * num, -cellHeight * num2, z)); if (++num >= maxPerLine && maxPerLine > 0) { num = 0; num2++; } } j++; } } else { for (Int32 k = 0; k < transform.childCount; k++) { Transform child2 = transform.GetChild(k); if (NGUITools.GetActive(child2.gameObject) || !hideInactive) { Single z2 = child2.localPosition.z; child2.localPosition = ((arrangement != Arrangement.Horizontal) ? new Vector3(cellWidth * num2, -cellHeight * num, z2) : new Vector3(cellWidth * num, -cellHeight * num2, z2)); if (++num >= maxPerLine && maxPerLine > 0) { num = 0; num2++; } } } } UIDraggablePanel uidraggablePanel = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (uidraggablePanel != null) { uidraggablePanel.UpdateScrollbars(true); } }
public void RepositionEx(bool isByNum = false, float inter = 0.0f) // 使用数字顺序时需要传参数true,其余情况下仍然走false的字典序 / { if (!mStarted) { repositionNow = true; return; } Transform myTrans = transform; int x = 0; int y = 0; if (sorted) { List <Transform> list = new List <Transform>(); for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (t && (!hideInactive || NGUITools.GetActive(t.gameObject))) { list.Add(t); } } if (isByNum) { list.Sort(SortByNum); } else { list.Sort(SortByName); } for (int i = 0, imax = list.Count; i < imax; ++i) { Transform t = list[i]; if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x + inter * y, -cellHeight * y, depth) : new Vector3(cellWidth * y + inter, -cellHeight * x, depth); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } else { for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x + inter * y, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x, depth); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } } UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } }
public void Notify(int panelType) { if (armorBtn == null) { armorBtn = GameObject.Find("tab_armor"); } if (weaponBtn == null) { weaponBtn = GameObject.Find("tab_weapon"); } if (shipinBtn == null) { shipinBtn = GameObject.Find("tab_shipin"); } if ((panelType & (int)PanelType.Panel_Bag) > 0) { if (copyItem != null && Instance.m_PanelList.Count != 0 && Instance.m_PanelList.ContainsKey(PanelType.Panel_Bag)) { float bagScrollValue = 0f; UIDraggablePanel panel = copyItem.transform.parent.GetComponent <UIDraggablePanel>(); if (panel != null) { if (isFirst) { bagScrollValue = 0; isFirst = false; } else { bagScrollValue = panel.verticalScrollBar.value; } panel.ResetPosition(); } Hashtable itemTable = sdGameItemMgr.Instance.GetAllItem(1, itemFilter); Hashtable list = Instance.m_PanelList[PanelType.Panel_Bag]; if (itemTable.Count > list.Count) { if (copyItem == null) { Debug.LogWarning("NoCopyItem"); } copyItem.SetActive(true); for (int i = list.Count; i < itemTable.Count; ++i) { GameObject tempItem = GameObject.Instantiate(copyItem) as GameObject; tempItem.transform.parent = copyItem.transform.parent; Vector3 pos = copyItem.transform.localPosition; pos.y -= i * 100; tempItem.transform.localPosition = pos; tempItem.transform.localScale = copyItem.transform.localScale; sdSlotIcon icon = tempItem.GetComponent <sdSlotIcon>(); if (icon != null) { icon.index = i; RegisterSlot(icon); } } } else if (itemTable.Count < list.Count) { foreach (DictionaryEntry item in list) { sdSlotIcon icon = item.Value as sdSlotIcon; if (icon != null && icon.index >= itemTable.Count) { if (icon.index == 0) { copyItem.SetActive(false); } else { icon.gameObject.SetActive(false); } } } } else { copyItem.SetActive(true); } if (panel != null) { panel.ResetPosition(); } IDictionaryEnumerator iter = list.GetEnumerator(); ArrayList itemList = new ArrayList(itemTable.Values); if (itemList != null) { itemList.Sort(); bool needRepos = false; if (itemLocation != HeaderProto.ERoleItemEquipSlot.RoleItemEquipSlot_Equip_Max) { needRepos = true; } foreach (sdGameItem info in itemList) { iter.MoveNext(); if (iter == null) { break; } //sdGameItem info = (sdGameItem)item.Value; if (info.bagIndex != (int)PanelType.Panel_Bag) { continue; } //if (info.slotIndex != num) continue; Hashtable table = new Hashtable(); sdSlotIcon icon = (sdSlotIcon)iter.Value; table.Add("uuid", info.instanceID); table.Add("ID", info.templateID); table.Add("count", info.count); icon.SetInfo(info.instanceID.ToString(), table); icon.gameObject.SetActive(true); if (needRepos && sdConfDataMgr.Instance().IsItemRightType(itemLocation, info.equipPos)) { UIDraggablePanel drag = icon.transform.parent.GetComponent <UIDraggablePanel>(); if (drag != null) { //drag.disableDragIfFits = false; drag.MoveRelative(-icon.transform.localPosition); drag.UpdateScrollbars(true); bagScrollValue = drag.verticalScrollBar.value; needRepos = false; itemLocation = HeaderProto.ERoleItemEquipSlot.RoleItemEquipSlot_Equip_Max; //drag.disableDragIfFits = true; sdRadioButton btn = null; if (itemFilter == (int)ItemFilter.Weapon) { btn = weaponBtn.GetComponent <sdRadioButton>(); } else if (itemFilter == (int)ItemFilter.Armor) { btn = armorBtn.GetComponent <sdRadioButton>(); } else if (itemFilter == (int)ItemFilter.Shipin) { btn = shipinBtn.GetComponent <sdRadioButton>(); } if (btn != null) { sdUICharacter.Instance.ActiceRadioBtn(btn); btn.Active(true); } } } else { if (itemFilter == lastFilter) { if (panel != null) { panel.verticalScrollBar.value = bagScrollValue; } } } } } lastFilter = itemFilter; } } if ((panelType & (int)PanelType.Panel_Equip) > 0) { if (Instance.m_PanelList.Count > 0 && Instance.m_PanelList.ContainsKey(PanelType.Panel_Equip)) { Hashtable list = Instance.m_PanelList[PanelType.Panel_Equip]; IDictionaryEnumerator iter = list.GetEnumerator(); Hashtable itemTable = sdGameItemMgr.Instance.GetAllItem(2, -1); if (itemTable != null) { while (iter.MoveNext()) { sdSlotIcon icon = (sdSlotIcon)iter.Value; if (icon == null) { continue; } bool findFlag = false; foreach (DictionaryEntry item in itemTable) { sdGameItem info = (sdGameItem)item.Value; if (info.bagIndex != (int)PanelType.Panel_Equip) { continue; } Hashtable tempItem = sdConfDataMgr.Instance().GetItemById(info.templateID.ToString()); if (tempItem != null) { int itemPos = int.Parse(tempItem["Character"].ToString()); if (itemPos == icon.index) { findFlag = true; } } if (findFlag) { Hashtable table = new Hashtable(); table.Add("uuid", info.instanceID); table.Add("ID", info.templateID); table.Add("count", info.count); icon.SetInfo(info.instanceID.ToString(), table); break; } } if (!findFlag) { icon.SetInfo("", null); } } } } } }
public void Reposition() { if (!this.mStarted) { this.repositionNow = true; return; } Transform transforms = base.transform; int num = 0; int num1 = 0; if (!this.sorted) { for (int i = 0; i < transforms.childCount; i++) { Transform child = transforms.GetChild(i); if (child.gameObject.activeInHierarchy || !this.hideInactive) { float single = child.localPosition.z; child.localPosition = (this.arrangement != UIGrid.Arrangement.Horizontal ? new Vector3(this.cellWidth * (float)num1, -this.cellHeight * (float)num, single) : new Vector3(this.cellWidth * (float)num, -this.cellHeight * (float)num1, single)); int num2 = num + 1; num = num2; if (num2 >= this.maxPerLine && this.maxPerLine > 0) { num = 0; num1++; } } } } else { List <Transform> transforms1 = new List <Transform>(); for (int j = 0; j < transforms.childCount; j++) { Transform child1 = transforms.GetChild(j); if (child1) { transforms1.Add(child1); } } transforms1.Sort(new Comparison <Transform>(UIGrid.SortByName)); int num3 = 0; int count = transforms1.Count; while (num3 < count) { Transform item = transforms1[num3]; if (item.gameObject.activeInHierarchy || !this.hideInactive) { float single1 = item.localPosition.z; item.localPosition = (this.arrangement != UIGrid.Arrangement.Horizontal ? new Vector3(this.cellWidth * (float)num1, -this.cellHeight * (float)num, single1) : new Vector3(this.cellWidth * (float)num, -this.cellHeight * (float)num1, single1)); int num4 = num + 1; num = num4; if (num4 >= this.maxPerLine && this.maxPerLine > 0) { num = 0; num1++; } } num3++; } } UIDraggablePanel uIDraggablePanel = NGUITools.FindInParents <UIDraggablePanel>(base.gameObject); if (uIDraggablePanel != null) { uIDraggablePanel.UpdateScrollbars(true); } }
public GameObject InsertItem(int index, GameObject prefab) { Transform myTrans = transform; bool itemAdded = false; int x = 0; int y = 0; List <Transform> list = new List <Transform>(); for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (t && (!hideInactive || NGUITools.GetActive(t.gameObject))) { list.Add(t); } } GameObject o = NGUITools.AddChild(gameObject, prefab); Transform item = o.transform; if (index == 0) { item.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, 0f) : new Vector3(cellWidth * y, -cellHeight * x, 0f); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } itemAdded = true; } for (int i = 0; i < list.Count; ++i) { Transform t = list[i]; if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } if ((index > 0) && (i == index)) { item.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, 0f) : new Vector3(cellWidth * y, -cellHeight * x, 0f); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } itemAdded = true; } float depth = t.localPosition.z; t.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, depth) : new Vector3(cellWidth * y, -cellHeight * x, depth); if (++x >= maxPerLine && maxPerLine > 0) { x = 0; ++y; } } if (!itemAdded) { item.localPosition = (arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * x, -cellHeight * y, 0f) : new Vector3(cellWidth * y, -cellHeight * x, 0f); } UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } return(o); }
// Token: 0x060000D7 RID: 215 RVA: 0x000197D0 File Offset: 0x000179D0 public void Reposition() { if (!this.mStarted) { this.repositionNow = true; return; } Transform transform = base.transform; int num = 0; int num2 = 0; if (this.sorted) { List <Transform> list = new List <Transform>(); for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (child && (!this.hideInactive || NGUITools.GetActive(child.gameObject))) { list.Add(child); } } list.Sort(new Comparison <Transform>(UIGrid.SortByName)); int j = 0; int count = list.Count; while (j < count) { Transform transform2 = list[j]; if (NGUITools.GetActive(transform2.gameObject) || !this.hideInactive) { float z = transform2.localPosition.z; transform2.localPosition = ((this.arrangement != UIGrid.Arrangement.Horizontal) ? new Vector3(this.cellWidth * (float)num2, -this.cellHeight * (float)num, z) : new Vector3(this.cellWidth * (float)num, -this.cellHeight * (float)num2, z)); if (++num >= this.maxPerLine && this.maxPerLine > 0) { num = 0; num2++; } } j++; } } else { for (int k = 0; k < transform.childCount; k++) { Transform child2 = transform.GetChild(k); if (NGUITools.GetActive(child2.gameObject) || !this.hideInactive) { float z2 = child2.localPosition.z; child2.localPosition = ((this.arrangement != UIGrid.Arrangement.Horizontal) ? new Vector3(this.cellWidth * (float)num2, -this.cellHeight * (float)num, z2) : new Vector3(this.cellWidth * (float)num, -this.cellHeight * (float)num2, z2)); if (++num >= this.maxPerLine && this.maxPerLine > 0) { num = 0; num2++; } } } } UIDraggablePanel uidraggablePanel = NGUITools.FindInParents <UIDraggablePanel>(base.gameObject); if (uidraggablePanel != null) { uidraggablePanel.UpdateScrollbars(true); } }
public void Reposition() { if (!mStarted) { repositionNow = true; return; } Transform transform = base.transform; int num = 0; int num2 = 0; if (sorted) { List <Transform> list = new List <Transform>(); for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if ((bool)child && (!hideInactive || NGUITools.GetActive(child.gameObject))) { list.Add(child); } } list.Sort(SortByName); int j = 0; for (int count = list.Count; j < count; j++) { Transform transform2 = list[j]; if (NGUITools.GetActive(transform2.gameObject) || !hideInactive) { Vector3 localPosition = transform2.localPosition; float z = localPosition.z; transform2.localPosition = ((arrangement != 0) ? new Vector3(cellWidth * (float)num2, (0f - cellHeight) * (float)num, z) : new Vector3(cellWidth * (float)num, (0f - cellHeight) * (float)num2, z)); if (++num >= maxPerLine && maxPerLine > 0) { num = 0; num2++; } } } } else { for (int k = 0; k < transform.childCount; k++) { Transform child2 = transform.GetChild(k); if (NGUITools.GetActive(child2.gameObject) || !hideInactive) { Vector3 localPosition2 = child2.localPosition; float z2 = localPosition2.z; child2.localPosition = ((arrangement != 0) ? new Vector3(cellWidth * (float)num2, (0f - cellHeight) * (float)num, z2) : new Vector3(cellWidth * (float)num, (0f - cellHeight) * (float)num2, z2)); if (++num >= maxPerLine && maxPerLine > 0) { num = 0; num2++; } } } } UIDraggablePanel uIDraggablePanel = NGUITools.FindInParents <UIDraggablePanel>(base.gameObject); if (uIDraggablePanel != null) { uIDraggablePanel.UpdateScrollbars(recalculateBounds: true); } }
/// <summary> /// Recalculate the position of all elements within the grid, sorting them alphabetically if necessary. /// </summary> public void Reposition(bool isByNum = false) // 使用数字顺序时需要传参数true,其余情况下仍然走false的字典序 / { if (!mStarted) { repositionNow = true; return; } Transform myTrans = transform; int x = 0; int y = 0; float fDeltaX = cellWidth; float fDeltaY = Mathf.Sqrt(Mathf.Pow(cellHeight, 2) - Mathf.Pow(cellWidth / 2, 2)); List <Transform> list = new List <Transform>(); for (int i = 0; i < myTrans.childCount; ++i) { Transform t = myTrans.GetChild(i); if (t && (!hideInactive || NGUITools.GetActive(t.gameObject))) { list.Add(t); } } if (sorted) { if (isByNum) { list.Sort(SortByNum); } else { list.Sort(SortByName); } } for (int i = 0, imax = list.Count; i < imax; ++i) { Transform t = list[i]; if (!NGUITools.GetActive(t.gameObject) && hideInactive) { continue; } float depth = t.localPosition.z; if (y % 2 == 0) { t.localPosition = arrangement == Arrangement.Horizontal ? new Vector3(fDeltaX * x, -fDeltaY * y, depth) : new Vector3(fDeltaX * y, -fDeltaY * x, depth); if (++x >= maxPerLine && maxPerLine > 1) { x = 0; ++y; } } else { t.localPosition = arrangement == Arrangement.Horizontal ? new Vector3(fDeltaX / 2 + fDeltaX * x, -fDeltaY * y, depth) : new Vector3(fDeltaX * y, -fDeltaY / 2 - fDeltaY * x, depth); if (++x >= maxPerLine - 1 && maxPerLine > 1) { x = 0; ++y; } } } UIDraggablePanel drag = NGUITools.FindInParents <UIDraggablePanel>(gameObject); if (drag != null) { drag.UpdateScrollbars(true); } }