I want to port my Gear VR app (created in Java using the official framework) to Unity, so I can also support Microsoft's new-ish VR headsets (not talking about the Hololens!).

In my current app I'm using OpenGL ES to draw everything I need (the app reads coordinates and additional information about what it has to draw from a .txt file), which is:

  1. GL_LINE_STRIP: The .txt file gives it a bunch of coordinate triples (x, y and z, so single vertices), it then has to automatically connects them (usually without loops)

  2. Kind of plane: Either display a rectangular plane with a texture (using the Gear VR framework's "GVRSceneObject") OR create an outline (usually first point = last point) that then gets filled in a specific color (GL_TRIANGLE_FAN) AND that is a little bit transparent - if it includes concave areas, it's using GL_TRIANGLES and the .txt file has coordinates for single triangles that have to be displayed at the same time and filled (it's still a single object/mesh!)

What I need Unity to do (with 1. and 2.):

  • Display a couple of 1. (could be up to 50 or more) and 1 of 2. at the same time (there'll never be more than 1 of type 2.!)

  • Remove all of 1. (that are displayed at the same time) or 2. from the scene and/or replace them with a couple of different 1. or another 2.

  • Group a couple of 1. together, so you can remove them at the same time (which would make stuff a lot easier)

  • Read .obj files (including their texture) from internal storage (Android) or the HDD (Windows) and display it/them instead of 2. (the .txt file includes the path to the file and texture)

Everything has to happen at runtime, since the app doesn't come with any .txt files or pre-imported .obj scenes/objects!

My question is:

How can I do this with Unity, targeting Windows and Android?

  • 1
    \$\begingroup\$ Please note that questions asking if something is doable with a piece of software is considered off-topic here. I reworded the question so that it fits within our scope. \$\endgroup\$
    – Vaillancourt
    Commented Feb 6, 2018 at 14:57
  • 1
    \$\begingroup\$ Asking for libraries is off-topic for this site (see the help), please don't ask for it again. \$\endgroup\$
    – Vaillancourt
    Commented Feb 6, 2018 at 15:29
  • \$\begingroup\$ Then where can I ask for one, since Unity doesn't seem to fully support everything I need? So many restrictions that don't make any sense... I don't even want to know HOW to do what my thread now asks (I'll try and look that up myself if it can, once I actually understand how Unity works), I just want to know if there's even a point to get into Unity on its own! Btw, I checked your help, I'm not asking what technology to use for my "game" idea but what "technology" can do what I need, if I'll then use it, that's a different question, so no, it's not off-topic. ;) \$\endgroup\$
    – Neph
    Commented Feb 7, 2018 at 9:27

1 Answer 1


Using native OpenGL functionality in Unity is going to be tricky. You might be able to get this to work on one platform with some dirty hacking, but I doubt you will manage to do it in a portable way.

You can generate procedural meshes in Unity. So you just need to write some code which takes your coordinates and uses them to build a Mesh component. You can then assign these meshes to game objects, set the right material on their renderer and you should be good to go.

Reading .obj files at runtime is a problem. The Unity Editor can import .obj 3d models, but it converts them into the Unity-specific 3d model format, which is the only format you can load at runtime. So when you want to load 3rd party content at runtime, that content must be in the Unity AssetBundle format. Unless, of course, you load it as a binary file and then build your mesh and texture using your own code.

Everything else you describe should be possible in Unity. But you are describing some very high-level concepts here. It will be very unlikely that you will be able to convert any of your Java code 1:1 into Unity code. You won't get around developing everything from scratch. I would recommend you to do some basic Unity tutorials to get a feeling for how the engine works and then recreate your game the Unity way.

  • \$\begingroup\$ I need it to work on both Android (Gear VR) and Windows (MS VR) and I'm only porting it to have the "one engine for everything" advantage (hopefully). It doesn't have to be OpenGL, I'm just wondering if there's something that's as easy-ish to do like OpenGL, since everything builds on it. With the GearVR framework creating meshes is pretty easy, you give it an array with the vertices (simply x1,y1,z1,x2,y2,z2,...), set the material, transparency, rendering order, shader, position of the finished object and the draw mode (which is the OpenGL ES type) and add it to the scene. \$\endgroup\$
    – Neph
    Commented Feb 6, 2018 at 14:57
  • \$\begingroup\$ Hm, the .obj thing is a problem then because I don't create these files but download them from a server that can only provide specific types. I'm guessing it can't do .fbx or the texture (jpg/png) then either at runtime? Do you know of any libraries that can do the conversion for you at runtime or maybe an extra Windows program that could be installed on the server? I already found the "Runtime OBJ Importer" but it doesn't seem to work on Android. Yes, I'm aware that I'll have to rewrite pretty much everything from scratch but no way to get around that with MS VR. ;) Thanks for your answer! \$\endgroup\$
    – Neph
    Commented Feb 6, 2018 at 15:12
  • \$\begingroup\$ @Neph is there a clear reason why the importer doesn't work at runtime? maybe it just requires a small bug fix \$\endgroup\$ Commented Feb 7, 2018 at 13:03
  • \$\begingroup\$ @Timothy Groote Are you talking about the "Runtime OBJ Importer"? To be honest, I don't know, it's what reviews say, a couple even say that importing works fine in Unity but once you actually export and use the program on Windows, it doesn't work either. Honestly, I'm not even remotely close to actually being able to even think about using it (haven't started doing anything with Unity yet). \$\endgroup\$
    – Neph
    Commented Feb 8, 2018 at 11:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .