Beispiel #1
0
    private void OnEnable()
    {
        bool enabled = true;

        for (int i = 0; i < LevelManager.Levels.Count; i++)
        {
            LevelSelectionItem item = ItemsGrid.GetChild(i).GetComponent <LevelSelectionItem>();
            TurningTallulah.Database.LevelData data = LevelManager.GetLevelData(i);

            item.Init(LevelManager.Levels[i].name, data, enabled);

            enabled = data != null;
        }
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        for (int i = 0; i < ItemsGrid.childCount; i++)
        {
            Destroy(ItemsGrid.GetChild(i).gameObject);
        }

        bool enabled = true;

        for (int i = 0; i < LevelManager.Levels.Count; i++)
        {
            LevelSelectionItem item = Instantiate(LevelItem, ItemsGrid).GetComponent <LevelSelectionItem>();
            TurningTallulah.Database.LevelData data = LevelManager.GetLevelData(i);

            item.ButtonClicked.AddListener(LevelItemClicked);
            item.Init(LevelManager.Levels[i].name, data, enabled);

            enabled = data != null;
        }
    }
    private void BuildMenu()
    {
        LevelSelectionController controller = target as LevelSelectionController;

        for (int i = controller.ItemsGrid.childCount - 1; i >= 0; i--)
        {
            DestroyImmediate(controller.ItemsGrid.GetChild(i).gameObject);
        }

        string[] fileEntries = Directory.GetFiles(Application.dataPath + "/_TurningTallulha/Levels");

        for (int i = 0; i < fileEntries.Length; i++)
        {
            if (fileEntries[i].EndsWith("meta"))
            {
                continue;
            }

            LevelSelectionItem item = (PrefabUtility.InstantiatePrefab(controller.LevelItem) as GameObject).GetComponent <LevelSelectionItem>();
            item.transform.SetParent(controller.ItemsGrid, false);

            item.Init(Path.GetFileName(fileEntries[i].Split('.')[0]), null, i < 4);
        }
    }