// Use this for initialization void Awake() { Instance = this; //if (exit != null) PlayerController.instance.transform.position = exit.transform.position; }
void LoadLevelResource(int levelNumber) { currentLevelNumber = levelNumber; // delete the current level if it exists if (currentLevel != null) { currentLevel.Save(); Destroy(currentLevel.gameObject); currentLevel = null; } // load the level resource and get the level object GameObject level = (GameObject)Instantiate(Resources.Load(levelNumber.ToString())); if (level == null) { Debug.Log("Could not load level " + levelNumber + " from Resources folder"); return; } // set the current level as the new level currentLevel = level.GetComponent<Level>(); }