Hi,
I’m making a run-time level editor and have ran into some issues while implementing a save feature. I have a large amount of different GameObjects
that can be added to the level. Instead of saving all of their components, I only need to save a few variables (for example the position). Instead of saving every GameObject
separately, I’d simply like to save some sort of reference to the prefab they use.
When loading, I could just use Resources.Load(...)
to load the prefab from the resources folder, saving me the trouble of having a reference to the prefab set up in the scene. Let’s say we have 1000 different prefabs. Maintaining a reference to them all manually from some collection in the scene wouldn’t be very plausible. I’d much rather load a GameObject
only when it’s actually used in the level.
I tried looking around but apparently the paths to prefabs can only be found while in the Unity editor (using the PrefabUtility
). What kind of a solution would let me get the prefab path of a GameObject
so that I could use Resources.Load()
during my level loading? Or is there perhaps some totally different way of approaching the problem that I haven’t thought about?
Thank you