4

I am not expert at Unity yet and I have an idea to present on 7th of August. I am a little worried about the feasibility of my idea.

My question is as follow: 1) is it possible to query 3d object from a database to unity scene?

if the answer to above question is yes, will I be able to add the components to it when adding it?

Your feedback is appreciated

1 Answers1

5

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.

Programmer
  • 121,791
  • 22
  • 236
  • 328