// Use this for initialization void Start() { //Grid Creator, Clear, Create, Rename GameObject[] rootObjects = SceneManager.GetActiveScene().GetRootGameObjects(); //loadedScene.GetRootGameObjects(); GameObject SquareGridRef = null; for (int i = 0; i < rootObjects.Length; i++) { if (rootObjects[i].name == "SquareGrid") { SquareGridRef = rootObjects[i]; break; } } SquareGridCreator creator = SquareGridRef.GetComponent <SquareGridCreator>(); creator.ClearGrid(); creator.CreateGrid(); creator.RenameGrid(); //Get Level Editor, Get Level of Index LevelEditor tempEditor = SquareGridRef.GetComponent <LevelEditor>(); Debug.Log("Load Level Index: " + levelIndex); tempEditor.getLevel(levelIndex); }
void GameLevelLoaded(Scene loadedScene, LoadSceneMode loadMode) { if (loadedScene.buildIndex == 1) { //Load Level if we have Reference to Scene //Grid Creator, Clear, Create, Rename GameObject[] rootObjects = loadedScene.GetRootGameObjects(); GameObject SquareGridRef = null; for (int i = 0; i < rootObjects.Length; i++) { if (rootObjects[i].name == "SquareGrid") { SquareGridRef = rootObjects[i]; break; } } SquareGridCreator creator = SquareGridRef.GetComponent <SquareGridCreator>(); creator.ClearGrid(); creator.CreateGrid(); creator.RenameGrid(); //Get Level Editor, Get Level of Index LevelEditor tempEditor = SquareGridRef.GetComponent <LevelEditor>(); Debug.Log("Load Level Index: " + levelIndex); tempEditor.getLevel(levelIndex); SceneManager.sceneLoaded -= GameLevelLoaded; creator.LevelComplete += LevelCompleted; } }
void CreateGrid() { SquareGridCreator creator = (SquareGridCreator)target; creator.CreateGrid(); }