Question by
jertiri · Aug 01, 2016 at 10:11 AM ·
gameobjectdestroystatic
Static Gameobjects Destroy on Reload
Hi a recursiv Ask for you :
I want Dont destroy Gameobjects after Reload Scene.
Game Object CFunc ist not createt in Scene
COde OF CFUNC
public class CFunctions : Singleton<CFunctions>
{
static GameObject ScoreManager = GameObject.Find("ScoreManager");
static GameObject PreviewPic = GameObject.Find("PreviewPic");
static GameObjectPreviewTextUpImg = GameObject.Find("PreviewTextUpImg");
// AND TOO MUCH MORE
}
Code of SIngleton
public abstract class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
private static T instance;
public static T Instance
{
get
{
if (instance == null) instance = FindObjectOfType<T>();
return instance;
}
}
}
RELOAD SCENE LOOK THIS
public void restartmatch()
{
int scene = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(scene, LoadSceneMode.Single);
}
SO i thought with a on Awake functions use
DontDestroyOnLoad(gameObject)
I think its saved the Cfunc singleton but the inside static Methods dont save . I get continuly The Gameobject has been destroyed error, on line where i use the first Gobj
Thanks For Helping Greets Richie
Comment
Your answer
Follow this Question
Related Questions
If you want to destroy the game object, please call 'Destroy' on the game object instead. 1 Answer
Make an object move from Point A to Point B then back to Point A, and then destroy itself 1 Answer
Keep GameObject destroyed on returning to the scene 1 Answer
How to destroy child of GameObject? 1 Answer