Created
July 4, 2017 15:22
-
-
Save anzfactory/ba3cda8aa8a698da3173a690f73979d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************* | |
さんぷる | |
*********************************/ | |
using UnityEngine; | |
using UnityEngine.UI; | |
using System.Collections.Generic; | |
using Xyz.AnzFactory.UI; | |
public class ListViewController : MonoBehaviour, ANZListView.IDataSource, ANZListView.IActionDelegate | |
{ | |
#region "Serialize Fields" | |
[SerializeField] private Font font; | |
[SerializeField] private ANZListView listView; | |
#endregion | |
#region "Fields" | |
private List<string> items; | |
#endregion | |
#region "Lifecycle" | |
private void Awake() | |
{ | |
this.listView.DataSource = this; | |
this.listView.ActionDelegate = this; | |
} | |
private void Start() | |
{ | |
this.items = new List<string>(); | |
items.Add("あいてむ1"); | |
items.Add("あいてむ2"); | |
items.Add("あいてむ3"); | |
items.Add("あいてむ4"); | |
items.Add("あいてむ5"); | |
items.Add("あいてむ6"); | |
items.Add("あいてむ7"); | |
items.Add("あいてむ8"); | |
items.Add("あいてむ9"); | |
items.Add("あいてむ10"); | |
this.listView.ReloadData(); | |
} | |
#endregion | |
#region "ANZListView.IDataSource" | |
public int NumOfItems() | |
{ | |
return this.items.Count; | |
} | |
public float HeightItem() | |
{ | |
return 50f; | |
} | |
public GameObject ListViewItem(int index, GameObject item) | |
{ | |
Text t; | |
if (item == null) { // 新規作成 | |
item = new GameObject("Item"); | |
t = item.AddComponent<Text>(); | |
t.color = Color.black; | |
t.alignment = TextAnchor.MiddleCenter; | |
t.font = this.font; // SerializeFieldで設定されてるフォント | |
} else { | |
t = item.GetComponent<Text>(); | |
} | |
t.text = this.items[index]; | |
return item; | |
} | |
#endregion | |
#region "ANZListView.IActionDelegate" | |
public void TapListItem(int index, GameObject listItem) | |
{ | |
Debug.Log(this.items[index] + "がたっぷされたよ!"); | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment