- Home /
How could I save my Gameobject inside a defined Prefab ?
Hi guys,
So in my scene I have a sphere, through script and UI I'm able to change the size, the material and the texture of the sphere ... I would like to save my sphere with those parameters that I have chosen (size, material and color) inside a defined Prefab. Of course in runtime and via C# script
If anyone could help that would be a lot of help :D, thanks !
Answer by BaldBeardedMonk · Apr 28, 2017 at 06:01 AM
This has already been answered before. CreatePrefab method should do it for you.
http://answers.unity3d.com/questions/784916/saving-runtime-generated-gameobjects-to-prefabs.html
I'm kind of beginner in scripting so I do not know how to start my C# script ... And in fact I already have a prefab , I would like to save my gameobject from the hierarchy to this particular prefab.
Any ideas ? Thanks :)
You can simply drag the desired GameObject from the hierarchy into the Project window (where you have all your assets) It creates a prefab for you.
It's exactly what I would like to do but via C# script :)