Create Prefab at Runtime = Possible?

Hey ,

I just wanted to ask if its possible to create a Prefab at runtime or change a prefab at runtime.
E.g. I want to load a Character Prefab change things at runtime and want to save them.Is this
possible or is there another way of doing it?

Hope you guys can help me or give me a hint.

Raison

No, that is not possible.

So there is no way around?Is there only the way to use PlayerPrefs to change Variables and save them?

You can save anything you want with PlayerPrefs. What I meant was that you can’t save/change a prefab at runtime.

So actually what i want to get is a simple way to save all things behave to the character. Hope anyone know a easy way because
calling 100x PlayerPrefs isnt that what i want.

Hope anyone knows a answer.

A Prefab is just a copy of a GameObject that’s not in a scene. Depending on what you want, you could simply keep an inactive copy of your template GameObject hidden in your scene, change that as you wish, and use it rather than a “prefab” as the argument when you call Instantiate.

Another alternative is to keep the stuff you want to be able to change in a separate data object, and apply the data to your object upon instantiation. The data object can be stored and loaded as per any other .NET object - remember that you have full access to serialization, file IO, and so on and so forth (except for when using the web player, where file IO is restricted - look to use network based methods there instead).

Also, you’re right, calling hundreds of PlayerPrefs isn’t a good idea. Just looking at the name gives a pretty good indicator that the system is intended to store preferences, not bulk data.

You should look into ScriptableObject to store your data, but you still have to store and load it like angrypenguin said via IO stuff or http, depending on your target.

Thanks for the help.