It is possible an here's what to do:
1.Store the 3D object as a binary data in the database in its original format such as .fbx
and .obj
.
2.When you need to retrieve it, don't connect directly to your database directly from Unity. Connect to your server which has a script(php) that retrieves the 3D object from a database. You can do this with a POST request using the UnityWebRequest
API and a form that specifies which 3D object you want to retrieve. Your server code(php)should the connect to the database, retrieve the 3D object then return it your Unity app.
3.Create a new GameObject to hold the 3D object. Attach MeshRenderer
and MeshFilter
to it with the GameObject.AddComponent
function then create new material for it. Load the 3D object with FastObjImporter
and assign the mesh MeshFilter
. This step is basically covered here. Depending on the 3D object format, you may need a different plugin to convert it it Unity's mesh format. The FastObjImporter
plugin is for .obj
format.