private void CreateItems() { this.ClearAll(); List <GameObject> items = new List <GameObject>(); foreach (AdvSelection selection in this.SelectionManager.Selections) { GameObject item = Object.Instantiate <GameObject>(this.GetPrefab(selection)); AdvUguiSelection componentInChildren = item.GetComponentInChildren <AdvUguiSelection>(); if (componentInChildren != null) { componentInChildren.Init(selection, new Action <AdvUguiSelection>(this.OnTap)); } switch (this.selectedColorMode) { case SelectedColorMode.Change: if (this.Engine.SystemSaveData.SelectionData.Check(selection)) { item.SendMessage("OnInitSelected", this.selectedColor); } break; } this.Items.Add(item); if (!selection.X.HasValue || !selection.Y.HasValue) { items.Add(item); } else { base.get_transform().AddChild(item, new Vector3(selection.X.Value, selection.Y.Value, 0f)); } } this.ListView.AddItems(items); this.ListView.Reposition(); }
//リストビューのアイテムが作成されるときに呼ばれるコールバック protected virtual void CallbackCreateItem(GameObject go, int index) { AdvSelection data = SelectionManager.Selections[index]; AdvUguiSelection selection = go.GetComponentInChildren <AdvUguiSelection>(); selection.Init(data, OnTap); }
//選択肢が押された void OnTap(AdvUguiSelection item) { SelectionManager.Select(item.Data); ClearAll(); }
//選択肢を作成 protected virtual void CreateItems() { ClearAll(); List <GameObject> listViewItems = new List <GameObject>(); foreach (var data in SelectionManager.Selections) { GameObject go = GameObject.Instantiate(GetPrefab(data)) as GameObject; AdvUguiSelection selection = go.GetComponentInChildren <AdvUguiSelection>(); if (selection) { selection.Init(data, OnTap); } switch (selectedColorMode) { case SelectedColorMode.Change: if (Engine.SystemSaveData.SelectionData.Check(data)) { go.SendMessage("OnInitSelected", selectedColor); } break; case SelectedColorMode.None: default: break; } Items.Add(go); //X,Y座標の指定がないならリストビューに追加 if (data.X == null || data.Y == null) { listViewItems.Add(go); } else { this.transform.AddChild(go, new Vector3(data.X.Value, data.Y.Value, 0)); } } ListView.AddItems(listViewItems); ListView.Reposition(); }
/// <summary> /// 初期化。スクリプトから動的に生成する場合に /// </summary> /// <param name="engine">ADVエンジン</param> public void InitOnCreate(AdvEngine engine, AdvUguiSelection selectionItemPrefab) { this.engine = engine; this.ListView.ItemPrefab = selectionItemPrefab.gameObject; }
//選択肢が押された void OnTap(AdvUguiSelection item) { SelectionManager.Select(item.Data ); ClearAll(); }
/// <summary> /// 初期化。スクリプトから動的に生成する場合に /// </summary> /// <param name="engine">ADVエンジン</param> public void InitOnCreate(AdvEngine engine, AdvUguiSelection selectionItemPrefab) { this.engine = engine; this.ListView.ItemPrefab = selectionItemPrefab.gameObject; }