赞
踩
把该脚本挂载到场景切换控制器下
DontDestroyOnLoad(dontDestory);//切换场景不销毁clone
public GameObject dontDestory; //预制体(不销毁的物体(做成预制体)) private GameObject clone;//克隆的不销毁物体 void Start() { clone = GameObject.Find("ChangeScenes(Clone)"); clone = Instantiate(dontDestory, transform.position, transform.rotation) as GameObject; } } void OnGUI() { if (GUILayout.Button("场景1")) { changeScenes("场景名称1"); } if (GUILayout.Button("场景2")) { changeScenes("场景名称2"); } } void changeScenes(string name) { DontDestroyOnLoad(dontDestory);//切换场景不销毁clone SceneManager.LoadScene(name);//level1为我们要切换到的场景 }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。