1. 程式人生 > >unity切換場景保留不需要刪除的東西

unity切換場景保留不需要刪除的東西

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class bu: MonoBehaviour {
//public GameObject zhu;
//public GameObject cu;
public Vector3 z;

void Awake()
{
   z = new Vector3(0, 2, 0);
    DontDestroyOnLoad(this);
    //DontDestroyOnLoad(cu);
    SceneManager.LoadScene(1);
   this.transform.position = z;

}

}