コード例 #1
0
ファイル: MenuManager.cs プロジェクト: deqyra/MidiVR
    private void Start()
    {
        float height           = menuItemPrefab.GetBodyMeshRenderer().bounds.size.y;
        float firstElementYPos = 0;
        float elementDistance  = height * 1.5f;

        int index = 0;

        foreach (MenuObjectMap m in prefabs)
        {
            MenuItemManager instance = Instantiate(menuItemPrefab);
            instance.transform.SetParent(transform, false);
            instance.transform.localPosition = new Vector3(0, firstElementYPos + (index * elementDistance), 0);
            instance.SetIndex(index);
            instance.SetText(m.name);
            instance.SetMenu(this);

            index++;
        }

        if (instantiateFirst)
        {
            if (index > 0)
            {
                InstantiateObject(0);
            }
            else
            {
                Debug.Log("No prefabs were registered in menu!");
            }
        }
    }