12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace Kasizuki
- {
- public class KasizukiItemCtrl : NGUIWindow
- {
- private void Start()
- {
- UIToggle componentInChildren = this.listViewer.tempItem.GetComponentInChildren<UIToggle>();
- UISprite component = componentInChildren.GetComponent<UISprite>();
- this.m_ItemDefaultColor = component.color;
- this.m_ItemSelectColor = new Color(1f, 1f, 1f, 1f);
- }
- public void SetData()
- {
- this.UpdateUI();
- }
- private void UpdateUI()
- {
- List<ItemData.Data> itemList = ItemData.GetAllDatas(true);
- this.listViewer.Show<Transform>(itemList.Count, delegate(int index, Transform trans)
- {
- ItemData.Data data = itemList[index];
- UIToggle componentInChildren2 = trans.GetComponentInChildren<UIToggle>();
- UISprite componentInChildren3 = trans.GetComponentInChildren<UISprite>();
- EventDelegate.Add(componentInChildren2.onChange, new EventDelegate.Callback(this.OnClick));
- });
- UITable component = this.listViewer.parentItemArea.GetComponent<UITable>();
- component.repositionNow = true;
- UIScrollView componentInChildren = base.GetComponentInChildren<UIScrollView>();
- componentInChildren.UpdatePosition();
- componentInChildren.ResetPosition();
- }
- private void OnClick()
- {
- UIToggle current = UIToggle.current;
- UISprite component = current.GetComponent<UISprite>();
- component.color = ((!current.value) ? this.m_ItemDefaultColor : this.m_ItemSelectColor);
- if (this.CallbackOnClick != null)
- {
- this.CallbackOnClick();
- }
- }
- private uGUIListViewer listViewer
- {
- get
- {
- if (!this.m_ListViewer)
- {
- this.m_ListViewer = base.GetComponent<uGUIListViewer>();
- }
- return this.m_ListViewer;
- }
- }
- public Action CallbackOnClick { get; set; }
- private uGUIListViewer m_ListViewer;
- private Color m_ItemDefaultColor;
- private Color m_ItemSelectColor;
- }
- }
|