public GameObject CopyPersistentGameObjects(GameObject localGOs, LocalScenePersistentGameObjects localScript)
    {
        //Check if there is already a copy stored...
        for(int i = 0; i < persistentData.localScenePersistentContainers.Count; i++){
            GameObject go = persistentData.localScenePersistentContainers[i];
            //If there is a copy, destroy it...
            if(go.GetComponent<LocalScenePersistentGameObjects>()){
                LocalScenePersistentGameObjects lspgo = go.GetComponent<LocalScenePersistentGameObjects>();
                if(lspgo.localScene == thisLocalScene && lspgo.isCopy){
                    persistentData.localScenePersistentContainers.Remove (go);
                    Destroy (go);
                }
            }
        }

        //Change isCopy before instantiation, so the new persistent gameobjects get catalogued as a copy correctly...
        //localScript.isCopy = true;
        //Instantiate a copy of the persistent gameobjects...
        GameObject localGOsCopy = Instantiate(localGOs, localGOs.transform.position, localGOs.transform.rotation) as GameObject;
        //Reset the current version's isCopy bool...
        //localScript.isCopy = false;
        //Set the copy to inactive...
        localGOsCopy.SetActive (false);
        return localGOsCopy;
    }
 void Start()
 {
     sceneFadeInOut = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<SceneFadeInOut>();
     if(GameObject.FindGameObjectWithTag(Tags.localScene)){
         localSceneObjectsExist = true;
         localScenePersistentGameObjects = GameObject.FindGameObjectWithTag(Tags.localScene).GetComponent<LocalScenePersistentGameObjects>();
     }
     if(localSceneObjectsExist){
         if(!ignoreScriptedEventForSceneClearing && !localScenePersistentGameObjects.isCleared){
             StartCoroutine(DelayedListAdd ());
         }
     }
 }
    void Awake()
    {
        persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();

        //This tests to see if a LocalScenePersistentGameObject already exists within the persistent data for this scene.
        if(persistentData.localScenePersistentContainers.Count > 0){
            for(int i = 0; i < persistentData.localScenePersistentContainers.Count; i ++){
                GameObject go = persistentData.localScenePersistentContainers[i];
                if(go.GetComponent<LocalScenePersistentGameObjects>()){
                    localScenePersistentGameObjects = go.GetComponent<LocalScenePersistentGameObjects>();
                    if(localScenePersistentGameObjects.localScene == localScene){
                        if(localScenePersistentGameObjects.isCopy){
                            go.SetActive(false);
                            copyExists = true;
                        }
                        else {
                            go.SetActive(true);
                            exists = true;
                        }
                    }
                    else{
                        go.SetActive(false);
                    }
                }
            }
            if(exists && copyExists){
                //If it already exists and a copy already exists, then destroy this...
                Destroy (gameObject);
            }
            else if (exists && !copyExists){
                //If it already exists, but a copy does not exist, then make this the copy and save it to the persistent list...
                isCopy = true;
                persistentData.localScenePersistentContainers.Add (gameObject);
            }
            else if(!exists && !copyExists){
                //It does not exist, or this is a Copy; add this copy to the persistent list...
                persistentData.localScenePersistentContainers.Add (gameObject);
            }
            else{
            }
        }
        else{
            //It does not exist, add this to the persistent list...
            persistentData.localScenePersistentContainers.Add (gameObject);

        }
        //persistentData.gameObjectsDoNotDestroyList.Add (gameObject);
        DontDestroyOnLoad (gameObject);
    }
    void Start()
    {
        sceneFadeInOut = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<SceneFadeInOut>();
        if(GameObject.FindGameObjectWithTag(Tags.localScene)){
            localScenePersistentGameObjects = GameObject.FindGameObjectWithTag(Tags.localScene).GetComponent<LocalScenePersistentGameObjects>();
            localSceneObjectsExist = true;
        }

        if(localSceneObjectsExist){
            if(!ignoreEnemyForSceneClearing && gameObject.tag == Tags.enemy && !localScenePersistentGameObjects.isCleared){
                //If this gameObject is tagged "enemy", then add it to the enemy list
                StartCoroutine(DelayedListAdd());
            }
        }
    }
    void Update()
    {
        //Sort out persistent gameobjects...
        if(!localPersistentSet){
            if(GameObject.FindGameObjectWithTag(Tags.localScene)){
                localPersistentGOs = GameObject.FindGameObjectWithTag(Tags.localScene);
                localPersistentScript = localPersistentGOs.GetComponent<LocalScenePersistentGameObjects>();
                //Create copy of persistent GameObjects...
                localPersistentGOsCopy = CopyPersistentGameObjects(localPersistentGOs, localPersistentScript);
                localPersistentSet = true;
            }
        }

        //Respawn logic...
        if (Input.GetKeyDown (KeyCode.Tab) && Application.loadedLevel != 1 && !disableRespawn && !pauseMenuController.isPaused && player == null) {
            resetLocalObjects = true;
            tempNextScene = thisScene;
            EndScene ();
        }
    }
    void ChangeScene()
    {
        //Continue with scene change:
        if(localPersistentGOs){
            //reset local persistent gameobjects to copy version...
            if (resetLocalObjects || !localPersistentScript.isCleared) {
                if(resetLocalObjects){
                }
                else if(!localPersistentScript.isCleared){
                }
                Destroy(localPersistentGOs);
                persistentData.localScenePersistentContainers.Remove (localPersistentGOs);
                localPersistentGOsCopy.SetActive (true);
                localPersistentGOsCopy.GetComponent<LocalScenePersistentGameObjects> ().isCopy = false;
                localPersistentGOs = localPersistentGOsCopy;
                localPersistentScript = localPersistentGOs.GetComponent<LocalScenePersistentGameObjects>();
                localPersistentGOsCopy = CopyPersistentGameObjects(localPersistentGOs, localPersistentScript);

            }
            //else, save a copy of the existing state as the copy version...
            else {
                localPersistentGOsCopy = CopyPersistentGameObjects(localPersistentGOs, localPersistentScript);
            }
        }

        /*ENABLE FOR ADDITIVE LOADING
        //Find all Transforms...
        allGameObjectsWithTransforms = Resources.FindObjectsOfTypeAll (typeof(GameObject)) as GameObject[];
        List<GameObject> realList = new List<GameObject> ();
        GameObject tempGameObject = new GameObject();
        tempGameObject.transform.SetAsFirstSibling();
        foreach (GameObject GO in allGameObjectsWithTransforms){
            //get the root transform...
            Transform rootObject = GO.transform.root;
            if(!realList.Contains (rootObject.gameObject)){
                if(rootObject.GetSiblingIndex() != 0 && !persistentData.gameObjectsDoNotDestroyList.Contains (rootObject.gameObject)){
                    realList.Add(rootObject.gameObject);
                }
            }
        }
        Destroy(tempGameObject);
        persistentData.realGameObjectsToDestroyListArray = realList.ToArray ();
        persistentData.ChangeSceneAdditive(tempNextScene);
        ENABLE FOR ADDITIVE LOADING*/

        //DISABLE FOR ADDITIVE LOADING
        Application.LoadLevel(tempNextScene);
        //DISABLE FOR ADDITIVE LOADING
    }