- Home /
[Probably an easy question]Troubles saving my GameObject through scenes
I have got a a mod and gun carcas prefabs of my ship which are saved on my ship script. My ships game object (with ships script) is DontDestroyOnLoad() so when I enter a station(a new scene!), I can Instantiate these gun and mod carcas prefabs in my ship window:
I instantiate it inside my scene then I drag and drop my mods or guns onto it and I need to save it! But if I replace the mod carcas reference on my playership(which is as I said a prefab right now and so can travel through scenes), but if I change this carcas refrence from prefab to this instance of the prefab I am gonna lose it if my instance gets destroyed(which happpens when I switch to another carcas(gun) or exit the station!!) so I lose all my gun and mod info!!!
I saw 3 ways:
1 Modifying a prefab itself to be like its instance(but it causes an error cause I have to destroy its children at runtime...Exception is smth like: Cant destoy assets at runtime cause memory problems can occur
2 Having my carcas somehow be DontDestroyOnLoad() but it is gonna be ugly and inconvinient!!!
3 Maybe using an external file to save it....but...I will have to save it very often at runtime so I dont think it is a good choice + confusing
I bet it is just me being dumb but please help me :(
Answer by LocalNoob · Jul 19, 2017 at 09:32 PM
I took approach number 2....But there must be a better way