예제 #1
0
    void changeScene()
    {
        Level obj = selectedObject.GetComponent <Level> ();

        Debug.Log("the level you clicked on is " + obj.level);
        if (obj.isLocked)
        {
            print("level is locked");
            return;
        }
        // get level
        string key = obj.level;

        print("changeScene - going to look for key: " + key);
        LevelData lvl = levelMap[key];

        print("changeScene - lvl: " + lvl);

        // update level data object
        GameObject         lvlDataObj  = GameObject.Find("LevelDataObj");
        PersistentLevelObj levelScript = lvlDataObj.GetComponent <PersistentLevelObj>();

        levelScript.data = lvl;

        print("changeScene - going to change to level " + lvl.scene);
        SceneManager.LoadScene(lvl.scene);
    }
예제 #2
0
    void Awake()
    {
        DontDestroyOnLoad(this);

        if (selfInstance == null)
        {
            selfInstance = this;
        }
        else
        {
            DestroyObject(gameObject);
        }
    }