Hello.
I’m trying to find a way to save a scene game object that was actually instantiated from HDD in runtime to disk as a prefab. Unfortunately all the materials gone after using the UnityEditor.PrefabUtility.CreatePrefab
method.
So I tried to use Assets Bundle but I don’t know how to build the AssetBoundle from the game object (which was generated at runtime).
Interestingly, You can save a prefab of the Game Object via drag and drop in the editor like a piece of cake, But I have no idea why doing so via script looks impossible!!
More details: The game object that I’m talking about is a car which player can customize it, After the player saves the car, the car should be save to the disk and should be loaded later. I hope I described the problem clearly.
EDIT: It is possible to store a copy of materials and assign them to the instantiated prefab but I don’t think it is the best way around.
As far as I know, it’s not possible. You basically would have to have a base car prefab that you use as a base model. Then you’d probably have a car script which would describe the car. If a person makes changes, you store these changes in that script variables. If a player saves their changes, you save that data to a file or online service. When the player returns to the game, you load up their changes and apply it to the car so it looks like what they left it at.
1 Like
Hmm how about the AssetDatabase interface, can’t we do anything with that for this case?.
I looked at the manual and found this:
Therefore I should not use it, yup the best way I can do, is apparently what @Brathnann said.
Thanks for the reply.
You might also consider a ScriptableObject to hold the data about what the user has customised on their car.
Yup good tips thanks, I actually am using XML parsing (TXT file) and is really cool.