I want to use an external file to “build” a scene in Unity (Import a .obj-file in specific position and set parameters like color, Rotation, …)
The general VR-scene will already be created in Unity. When I open the scene, I want Unity to use the information out of my .txt file to automatically import a obj-objects as my gameobject (body and rotors). I want the Gameobject to be placed in a special hirachry, which i would create out of empty Objects.
The .txt-file shall include the name of the to-be-imported obj-file,its folder location and data for its position/placement within the scene, color,…
The goal of this project is that a user, who has no knowledge of unity, is able to test out his object in VR by only configurating a simple .txt-file.
Do you think that this is even possible or would you reccommend a different filetype other than a simple .txt?
As I am new to unity and programming in c#, i would appriciate any help! Thanks!
What you want to do is possible and pretty cool @rozah.
Getting the text file is super easy, just look at System.IO and StreamReader. Using JSON filetype is also possible, but if you want anyone to be able to easily edit it I think .txt would be the best.
Once you’ve loaded the text file, you’ll need to save all the variables. Lists (Lists and Dictionaries - Unity Learn) are probably going to be the easiest for you to work with, where for each object you want to load you call the same index of each List (depending on how you save to the Lists).
After, depending on the text file, you would load the objects as Children of each other to create the hierarchy, which the user could also determine in the text file. This would give users much more flexibility than just using empty game objects you already have in the scene. But if you don’t want to do that it should be pretty similar, just give the empty objects the mesh renderers and colliders from the objects you load (through scripting of course).