- Home /
Export Prefabs at runtime
Hey, I just wanted to ask if it is possible to export a prefab at runtime by script. There is no asset folder in a built game so i cant copy it from there.
What do you mean by export? Can you be a little more specific?
I mean that you can export the .prefab file to your desktop and import and Instantiate them in another game.
Answer by Hellium · Jul 10, 2015 at 07:44 AM
I don't think exporting a prefab is possible. It doesn't make sense by the way since a prefab is meant to keep its values.
However, you can manage models and textures through the Resources folder and export data using Serialization for example. Take a look here for a simple example I made.
I think that wont work for me because I want to save several Planes with texture on the, and import them to their right position and with their texture on it in another game.
Then, it's totally possible to do this thanks to the method I proposed you :
Export planes, textures, etc,
Export position, path of the texture file into an X$$anonymous$$L file
Copy-paste everything from the Resources folder from the first application to the second one
Deserialize data, apply texture to planes, place your planes in your scene from the position serialized
Just a little question, have you simply tried to place the .prefab file in the Resources folder and instantiate it with the Resources.load method ?
Exporting models and textures is simply made by managing them from the Resources folder.
Just, don't forget, when you build your game, copy-paste all the folders and files you put in your Unity project's Resource folder into the applications's Resources folder.
http://docs.unity3d.com/$$anonymous$$anual/LoadingResourcesatRuntime.html
http://docs.unity3d.com/ScriptReference/Resources.html
When you will have to export, you will just have to copy-paste the assets inside the Resources folder from the first application to the second one.
Answer by Johnz1234 · Jul 09, 2015 at 05:58 PM
How you mean export you can Instantiate into the scene but not export as i know?
I mean that you can export the .prefab file to your desktop and import and Instantiate them in another game.