Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Vid

Pages: [1]
1
NGUI 3 Support / Re: adding list to UIGrid
« on: April 01, 2014, 08:08:07 AM »
but in this case it will be infinity loop or i`ve missed something?
  1. while (Grid.transform.childCount > 0)  - childCount always would be > 0
  2. {
  3.     Transform child = Grid.transform.GetChild(0);  - i don`t need get the first child i need to loop through all
  4.  
  5.     var childNew = child.transform.FindChild ( "Checkbox" ).GetComponent<UIToggle> ( );
  6.  
  7.     if ( childNew.value ) {
  8.                 NGUITools.Destroy ( child.gameObject );
  9.     }
  10.  
  11. }
  12.  

2
NGUI 3 Support / Re: adding list to UIGrid
« on: April 01, 2014, 06:19:33 AM »
Well, i used
  1. Destroy ( child.gameObject );
  2.  
and it works fine. But my Grid.GetComponent<UIGrid> ( ).Reposition ( ) - doesn`t work and my table doesn`t refresh. I tried like this
  1.             yield return new WaitForEndOfFrame ( );
  2.             Grid.GetComponent<UIGrid> ( ).Reposition ( );
  3.             Grid.transform.parent.GetComponent<UIPanel> ( ).Refresh ( );
  4.             yield return new WaitForEndOfFrame ( );
  5.  
but still no effect.
Any suggestions?

3
NGUI 3 Support / Re: adding list to UIGrid
« on: April 01, 2014, 05:47:38 AM »
Have someone any idea about why it remove only the half "checked" childrens?

4
NGUI 3 Support / Re: adding list to UIGrid
« on: March 31, 2014, 07:54:36 AM »
My script must to iterate through the grid, find out what childrens have active status "on" and delete this childrens.

UPD:i have modified the last piece of code a little and now it works, but not so right. By click, it removing only the half of checked children.
  1.     private void OnClick()
  2.     {
  3.         foreach (Transform child in Grid.transform)
  4.         {
  5.             var childNew = child.transform.FindChild ( "Checkbox" ).GetComponent<UIToggle> ( );
  6.             if ( childNew.isChecked )
  7.             {
  8.                 NGUITools.Destroy ( child.gameObject );
  9.             }
  10.         }
  11. }
  12.  

And i don`t know why this is happend, but my checkbox always visible when another gameObjects aren`t.

5
NGUI 3 Support / Re: adding list to UIGrid
« on: March 31, 2014, 06:11:35 AM »
Tnx, ArenMook, i used your advice and it`s worked fine.

But now i have another issue. I need to delete parentObject which contains UIToggle from UIGrid. In my grid i toggled needed records and after clicking on button should to delete their parentObject.

I`m write the following script but it works not as i expected. It works only if i toggle first record in grid and then it remove all records from current Grid.
  1. public GameObject Grid;
  2.  
  3. private void OnClick() {
  4.         GameObject parentItem = GameObject.Find ( "ListItem" );
  5.         var childItem =  parentItem.transform.FindChild ( "Checkbox" ).GetComponent<UIToggle> ( );
  6.         print ( childItem.isChecked );
  7.  
  8.         var obj = new List<GameObject> ( );
  9.  
  10.         foreach (Transform child in Grid.transform)
  11.         {
  12.             if ( childItem.isChecked )
  13.             {
  14.                 obj.Add(child.gameObject);
  15.                 obj.Remove(child.gameObject);
  16.             }
  17.  
  18.         }
  19.  
  20.  Grid.GetComponent<UIGrid> ( ).Reposition ( );
  21. }
  22.  

6
NGUI 3 Support / adding list to UIGrid
« on: March 27, 2014, 09:57:01 AM »
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.
  1. public class Add_btn1 : MonoBehaviour
  2. {
  3.  
  4.     public GameObject prefab;
  5.  
  6.     public UIInput name;
  7.     public UIInput age;
  8.     public UIInput date;
  9.     public Transform checkBox;
  10.  
  11.     public class Person
  12.     {
  13.         public string name;
  14.         public int age;
  15.         public string date;
  16.         public string gender;
  17.         public DateTime dt;
  18.         public bool check = false;
  19.     }
  20.  
  21.     public static List<Person> list = new List<Person>();
  22.  
  23.     private string Male = "Male";
  24.     private string Female = "Female";
  25.     private string datePattern = @"^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$";
  26.  
  27.     public GameObject Grid;
  28.     public GameObject ListItem;
  29.  
  30.     private void OnClick()
  31.     {
  32.  
  33.         //Create variables and checking condtions
  34.         Person p = new Person ( );
  35.  
  36.         var checkGender = checkBox.GetComponent<UIToggle>().isChecked;
  37.         string gender = !checkGender ? Female : Male;
  38.         DateTime pastDateTime = DateTime.ParseExact(date.value, "dd/MM/yyyy", null);
  39.         var intAge = Int32.Parse(age.value);
  40.  
  41.             p.name = name.value;
  42.             p.age = Int32.Parse(age.value);
  43.             p.date = pastDateTime.ToShortDateString();
  44.             p.gender = gender;
  45.  
  46.             //Add information to list
  47.             list.Add(p);
  48.  
  49.            foreach (var person in list) {}
  50.  
  51.         NGUITools.AddChild ( Grid, ListItem); // ListItem - my prepared test prefab
  52.  
  53.         GetComponent<UIGrid> ( ).Reposition ( );
  54.     }
  55. }
  56.  
  57.  

Pages: [1]