Is it possible to make an application where the user has the possibility to upload a file of graphics, have the application make a prefab from this file, assign a reference to the prefab and show the resulting graphics in the View?
I’ve implemented the result from those links. But it’s not quite a deep as I’d like it to be. I’m refering to making a brand new prefab during runtime out of and uploaded file. The part about uploading isn’t the real problem here. I guess that’s part of those lilnks. The real problem is how to construct a prefab during runtime out of the uploaded file.
You’d do something like this:
- create an empty GameObject
- load a mesh and a texture using the WWW class and perhaps a technique like this: http://www.unifycommunity.com/wiki/index.php?title=MeshSerializer
- add a MeshRenderer to the empty game object, and assign it the new mesh
- add a Material to the MeshRenderer and assign the new Texture2D to the Material
Now you place this object in a scene somewhere and you’re go. It won’t be a Prefab, but that’s simply because a Prefab is a Unity editor concept, that doesn’t apply to the running game.
This is not a one-liner script, but can be (and has been) achieved without much trouble.
d.