Question by
dnwsaa58 · Feb 18, 2018 at 09:13 PM ·
gameobjectscenedontdestroyonloadedit
Can I create a scene DontDestroyOnLoad in editing mode??
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<GameObject>())
DontDestroyOnLoad(a);
SceneManager.LoadScene(1);
}
}
Comment
Your answer
Follow this Question
Related Questions
modify a GameObject across multiple Scenes? 1 Answer
dontDestroyOnLoad doesn't work as expected with scene navigation 0 Answers
When going to a new scene, set gameObject position to its current co-ordinates. 1 Answer
GameObjects not appearing in scene view unless I zoom far out 0 Answers
CHANGING SCENE AND MAKE A GAME OBJECT ACTIVE THERE 0 Answers