void OnEnable() { instance = (LevelsGrid)target; if (instance.grid == null) { instance.grid = instance.GetComponentInChildren <GridLayoutGroup>(); } }
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); } }