Beispiel #1
0
 // Use this for initialization
 void Start()
 {
     clickManager = GameObject.Find("UI Root").GetComponent <ClickManager>();
     print("Items in click manager is " + clickManager.getItemNames().Length);
     foreach (string item in clickManager.getItemNames())
     {
         GameObject go = NGUITools.AddChild(gameObject, mainMenuItem);
         go.name = item;
         print("Item is " + item);
         go.GetComponentInChildren <UILabel>().text   = item.ToUpper() + "S";
         go.GetComponentInChildren <UISprite>().atlas = appUIAtlas;
         go.transform.GetChild(1).GetComponent <UISprite>().spriteName = item;
     }
     GetComponent <UIGrid> ().Reposition();
 }
    public void ReloadSubmenu(int index)
    {
        submenuTitle.GetComponent <UILabel>().text = clickManager.getItemNames()[index] + "s";
        NGUITools.DestroyChildren(submenuScrollview.transform);

        string name = clickManager.getItemNames()[index].Replace(" ", "").Replace("&", "and");

        print("name is " + name);

        if (clickManager.GetType().GetField(name + "Names") != null)
        {
            string[] submenuItems = (string[])clickManager.GetType().GetField(name + "Names").GetValue(clickManager);
            for (int i = 0; i < submenuItems.Length; i++)
            {
                GameObject submenuItem = NGUITools.AddChild(submenuScrollview, submenuItemPrefab);
                submenuItem.transform.GetComponent <SubmenuItem>().init(name, submenuItems[i]);
            }
            submenuScrollview.GetComponent <UIGrid>().Reposition();
        }
    }