I want some game object always exist in the game.
Can I create a scene and the things which are in it don't be destroyed when I go to another scene.
I have an idea but I wanna know if you guys have better method.
Thanks in advance.
the following is my method.
1.first create a scene and gameobject that you want them always exist.
2. create an empty gameobject and add the script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class gamemanager : MonoBehaviour {
void Awake()
{
foreach (GameObject a in FindObjectsOfType())
DontDestroyOnLoad(a);
SceneManager.LoadScene(1);
}
}
↧