| 12345678910111213141516171819202122232425262728293031323334353637 |
- /// <summary>
- /// ZWN
- ///跳转场景不删除
- /// 20220216
- /// </summary>
- using System.Collections;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class ZWN_DontDestroy : MonoBehaviour
- {
- //public GameObject ZWN_Dont_pc; //预制体(不销毁的物体(做成预制体))
- public GameObject ZWN_Dont_android; //预制体(不销毁的物体(做成预制体))
- private static bool isHave = false;
- private GameObject ZWN_Dont_Clone;//克隆的不销毁物体
- void Awake()
- {
- if (!isHave)
- {
- ZWN_Dont_Clone = GameObject.Instantiate(ZWN_Dont_android, transform.position, transform.rotation);
- isHave = true;
- }
-
- DontDestroyOnLoad(ZWN_Dont_Clone);//切换场景不销毁ZWN_Dont_Clone
- SceneManager.LoadSceneAsync(1);
- }
- /* private void Start()
- {
- StartCoroutine(LoadScene());
- }
- IEnumerator LoadScene()
- {
- yield return new WaitForSeconds(2f);
- SceneManager.LoadSceneAsync(1);
- }*/
- }
|