public void RemoveScrollContent(UIScrollContent content) { if (content == null) { return; } string key = content.id; if (dicRealContents.ContainsKey(key) == true) { GameObject go = dicRealContents[key]; dicRealContents.Remove(key); GameObject.Destroy(go); } listVirtualContents.Remove(content); CalculateBounds(); if (onUpdateScrollSection != null) { onUpdateScrollSection(); } }
public void InitalizeTitle(ref UIScrollContent content, GameObject go) { Title title = go.GetComponent <Title>(); if (title == null) { return; } title.labelName.text = content.id; }
public void InitalizeChampion(ref UIScrollContent content, GameObject go) { Champion champion = go.GetComponent<Champion>(); if (champion == null) return; champion.spriteIcon.atlas = atlas; champion.labelName.text = content.id; champion.spriteIcon.spriteName = content.id; }
public void AddScrollContent(UIScrollContent content, int index) { listVirtualContents.Insert(index, content); CalculateBounds(); if (onUpdateScrollSection != null) { onUpdateScrollSection(); } }
private void CreateItems() { // Title. { GameObject go = new GameObject(); go.name = "Title"; UIScrollSection section = go.AddComponent <UIScrollSection>(); section.contentWidth = 420f; section.contentHeight = 60f; section.arrangement = UIScrollSection.Arrangement.Vertical; go.AddComponent <UIScrollBlinker>(); UIScrollContent content = new UIScrollContent(); content.id = "Items"; content.prefab = prefabTitle; content.onInitContent = InitalizeTitle; section.AddScrollContent(content); section.CalculateBounds(); scrollBuilder.AddScrollSection(section); } // Items. { GameObject go = new GameObject(); go.name = "Items"; UIScrollSection section = go.AddComponent <UIScrollSection>(); section.arrangement = UIScrollSection.Arrangement.Vertical; section.contentWidth = 420f; section.contentHeight = 60f; section.arrangement = UIScrollSection.Arrangement.Vertical; go.AddComponent <UIScrollBlinker>(); foreach (string item in items) { UIScrollContent content = new UIScrollContent(); content.id = item; content.prefab = prefabItem; content.onInitContent = InitalizeItem; section.AddScrollContent(content); } section.CalculateBounds(); scrollBuilder.AddScrollSection(section); } }
private void CreateChampions() { // Title. { GameObject go = new GameObject(); go.name = "Title"; UIScrollSection section = go.AddComponent<UIScrollSection>(); section.contentWidth = 420f; section.contentHeight = 60f; section.arrangement = UIScrollSection.Arrangement.Vertical; go.AddComponent<UIScrollBlinker>(); UIScrollContent content = new UIScrollContent(); content.id = "Champions"; content.prefab = prefabTitle; content.onInitContent = InitalizeTitle; section.AddScrollContent(content); section.CalculateBounds(); scrollBuilder.AddScrollSection(section); } // Champions. { GameObject go = new GameObject(); go.name = "Champions"; UIScrollSection section = go.AddComponent<UIScrollSection>(); section.contentWidth = 420f; section.contentHeight = 60f; section.arrangement = UIScrollSection.Arrangement.Vertical; go.AddComponent<UIScrollBlinker>(); foreach (string champion in Champions) { UIScrollContent content = new UIScrollContent(); content.id = champion; content.prefab = prefabChampion; content.onInitContent = InitalizeChampion; section.AddScrollContent(content); } section.CalculateBounds(); scrollBuilder.AddScrollSection(section); } }
public void InitalizeChampion(ref UIScrollContent content, GameObject go) { Champion champion = go.GetComponent <Champion>(); if (champion == null) { return; } champion.labelName.text = content.id; champion.spriteIcon.atlas = atlasChampion; champion.spriteIcon.spriteName = content.id; }
public void InitalizeItem(ref UIScrollContent content, GameObject go) { Item item = go.GetComponent <Item>(); if (item == null) { return; } item.labelName.text = content.id; item.spriteIcon.atlas = atlasItem; item.spriteIcon.spriteName = content.id; }
public void AddScrollContent(UIScrollContent content) { if (content == null) { return; } listVirtualContents.Add(content); CalculateBounds(); if (onUpdateScrollSection != null) { onUpdateScrollSection(); } }
static int set_onPositionChange(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIScrollContent obj = (UIScrollContent)o; System.Action arg0 = (System.Action)ToLua.CheckDelegate <System.Action>(L, 2); obj.onPositionChange = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onPositionChange on a nil value")); } }
static int set_onSizeChange(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIScrollContent obj = (UIScrollContent)o; UnityEngine.Events.UnityEvent arg0 = (UnityEngine.Events.UnityEvent)ToLua.CheckObject <UnityEngine.Events.UnityEvent>(L, 2); obj.onSizeChange = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onSizeChange on a nil value")); } }
static int get_onPositionChange(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIScrollContent obj = (UIScrollContent)o; System.Action ret = obj.onPositionChange; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onPositionChange on a nil value")); } }
static int get_onSizeChange(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIScrollContent obj = (UIScrollContent)o; UnityEngine.Events.UnityEvent ret = obj.onSizeChange; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onSizeChange on a nil value")); } }
private void CreateChampions() { // Champions. { foreach (string champion in Champions) { UIScrollContent content = new UIScrollContent(); content.id = champion; content.prefab = prefabChampion; content.onInitContent = InitalizeChampion; scrollSection.AddScrollContent(content); } scrollSection.CalculateBounds(); } }
public void Refresh() { if (scrollView.panel == null) { return; } Vector3[] corners = scrollView.panel.worldCorners; for (int i = 0; i < 4; i++) { Vector3 v = corners[i]; v = transform.InverseTransformPoint(v); corners[i] = v; } Vector3 center = Vector3.Lerp(corners[0], corners[2], 0.5f); for (int i = 0; i < listVirtualContents.size; i++) { float minX = corners[0].x - contentWidth; float minY = corners[0].y - contentHeight; float maxX = corners[2].x + contentWidth; float maxY = corners[2].y + contentHeight; Vector3 pos = GetContentPosition(i); float distanceX = pos.x - center.x + scrollView.panel.clipOffset.x - transform.localPosition.x + contentWidth / 2f; float distanceY = pos.y - center.y + scrollView.panel.clipOffset.y - transform.localPosition.y - contentHeight / 2f; UIScrollContent content = listVirtualContents[i]; if (dicRealContents.ContainsKey(content.id) == true) { GameObject go = dicRealContents[content.id]; Vector3 dst = GetContentPosition(i); go.transform.localPosition = dst; } if ((distanceX > minX && distanceX < maxX) && (distanceY > minY && distanceY < maxY)) { MakeContent(i); } } }
private void MakeContent(int index) { if (listVirtualContents.size <= index) { return; } UIScrollContent content = listVirtualContents[index]; if (dicRealContents.ContainsKey(content.id) == true) { return; } GameObject go = NGUITools.AddChild(gameObject, content.prefab); go.name = content.id; go.transform.localPosition = GetContentPosition(index); if (automaticallyMakeBounds == true) { UIWidget widget = go.GetComponent <UIWidget>(); if (widget == null) { widget = go.AddComponent <UIWidget>(); } widget.width = (int)contentWidth; widget.height = (int)contentHeight; } dicRealContents.Add(content.id, go); if (content.onInitContent != null) { content.onInitContent(ref content, go); } }
public void AddScrollContent(UIScrollContent content) { if (content == null) return; listVirtualContents.Add(content); CalculateBounds(); if (onUpdateScrollSection != null) onUpdateScrollSection(); }
public void AddScrollContent(UIScrollContent content, int index) { listVirtualContents.Insert(index, content); CalculateBounds(); if (onUpdateScrollSection != null) onUpdateScrollSection(); }
public void RemoveScrollContent(UIScrollContent content) { if (content == null) return; string key = content.id; if (dicRealContents.ContainsKey(key) == true) { GameObject go = dicRealContents[key]; dicRealContents.Remove(key); GameObject.Destroy(go); } listVirtualContents.Remove(content); CalculateBounds(); if (onUpdateScrollSection != null) onUpdateScrollSection(); }
public void InitalizeItem(ref UIScrollContent content, GameObject go) { Item item = go.GetComponent<Item>(); if (item == null) return; item.labelName.text = content.id; item.spriteIcon.atlas = atlasItem; item.spriteIcon.spriteName = content.id; }
public void InitalizeTitle(ref UIScrollContent content, GameObject go) { Title title = go.GetComponent<Title>(); if (title == null) return; title.labelName.text = content.id; }