Hello.
Have some problem with adding information to UIGrid.
In my class i create 3 variables UIInput type, getting from this inputs values and add this values to list.
So, i want to add this list of info to my UIGrid as line. But i have no idea how to. The easiest way to do this, using NGUITools.AddChild(Grid, prefab) - but in this case i don`t know how to create prefab by my list of received info.
Thanks.
p.s.:Sry for my english.
public class Add_btn1 : MonoBehaviour
{
public GameObject prefab;
public UIInput name;
public UIInput age;
public UIInput date;
public Transform checkBox;
public class Person
{
public string name;
public int age;
public string date;
public string gender;
public DateTime dt;
public bool check = false;
}
public static List
<Person
> list
= new List
<Person
>();
private string Male = "Male";
private string Female = "Female";
private string datePattern = @"^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$";
public GameObject Grid;
public GameObject ListItem;
private void OnClick()
{
//Create variables and checking condtions
Person p
= new Person
( );
var checkGender = checkBox.GetComponent<UIToggle>().isChecked;
string gender = !checkGender ? Female : Male;
DateTime pastDateTime = DateTime.ParseExact(date.value, "dd/MM/yyyy", null);
var intAge = Int32.Parse(age.value);
p.name = name.value;
p.age = Int32.Parse(age.value);
p.date = pastDateTime.ToShortDateString();
p.gender = gender;
//Add information to list
list.Add(p);
foreach (var person in list) {}
NGUITools.AddChild ( Grid, ListItem); // ListItem - my prepared test prefab
GetComponent<UIGrid> ( ).Reposition ( );
}
}