LevelMenu.SetupItems C# (CSharp) Method

SetupItems() public method

public SetupItems ( string>.List inItems ) : void
inItems string>.List
return void
    public void SetupItems(List<Dictionary<string, string>> inItems)
    {
        Vector3 position = gameObject.transform.position;
        int index = 0;
        const float itemHeight = .15f;
        float startY = position.y;
        int cnt = inItems.Count;
        float totalHeight = cnt * itemHeight;

        foreach (Dictionary<string, string> item in inItems)
        {
          position.y = startY + ((cnt - index) * itemHeight);

          // center vertically
          position.y -= totalHeight / 2;

          GameObject anItem = Instantiate(itemPrefab, position, Quaternion.identity) as GameObject;

          anItem.transform.parent = gameObject.transform;

          LevelMenuItem menuItem = anItem.GetComponent<LevelMenuItem>() as LevelMenuItem;

          menuItem.SetupItem(item, this);

          index++;
        }
    }

Usage Example

Example #1
0
 void BuildMenuItems(LevelMenu menu, string category)
 {
     menu.SetupItems(AppCentral.APP.MenuItems(category));
 }
All Usage Examples Of LevelMenu::SetupItems