Пример #1
0
        void OnEnable()
        {
            instance = (LevelsGrid)target;

            if (instance.grid == null)
            {
                instance.grid = instance.GetComponentInChildren <GridLayoutGroup>();
            }
        }
Пример #2
0
    private void SetupGrid()
    {
        RemoveGrids();
        int levelCount = SceneManager.sceneCountInBuildSettings - 1;
        int gridCount  = Mathf.CeilToInt((float)levelCount / LevelsGrid.LEVELS_PER_GRID);

        for (int i = 0; i < gridCount; i++)
        {
            LevelsGrid grid  = Instantiate <LevelsGrid>(levelsGridPrefab, transform);
            int        start = i * LevelsGrid.LEVELS_PER_GRID;
            int        count = (levelCount - start) % LevelsGrid.LEVELS_PER_GRID;
            grid.SetupButtons(start, count, count);
        }
    }