Unity3D Runtime Import Library
Lab: File I/O import library supporting multiple formats and platforms.
** It is with my apologies that due to high levels of interest from other parties and ‘having to put food on the table’ as such, I am not disclosing further work based upon this initial library, the version below remains free for all to edit and use, but I have since improved the code for multiple platforms and made it much more object oriented so feel the code is a little too valuable to me to release gratis for this very moment. Please feel free to contact me if you have further enquiries with regards to this – Jon
——-
The aim of this project was to provide a cross platform all inclusive plug-in based library for Unity3d Pro users to aid developers trying to create runtime application based functionality in there own unity projects. The focus was on creating a solution that ran perfectly for PC /Mac standalone solutions, for instance see the space project which was an outcome of this work :http://space.fusedworks.com
The library was to hopefully offer Unity users things such as a file browser, processing bar, access to runtime mesh, texture, audio, video and material libraries, import support for OBJ, DAE, 3DS, and the standalone use of a DLL for conversion of H264, MP4, WMV to OGG THEORA and MP3, WAV, AIFF to OGG VORBIS (however the last part is still to be achieved).
The library as it exist below is released under MIT and certain import modules under their own MIT licenses, so it is fine for anyone to play with and utilise.
The what is included:-
- Load via inbuilt file browser complete with skinned GUI (non-web platforms only)
- Load via path (all target platforms)
- Load .OBJ & meshes & materials (all target platforms)
- Load .DAE & meshes & materials (all target platforms)
- Auto Progressive Mesh LowPoly Collision Generation
- Auto Scaling, Centering, Handles Parenting and Instances
- Project Creation Generation and File/Folder Handling
- Mesh Serialisation and Texture Saving to Project Folder
You can now download the Runtime Library version Alpha 0.4 here
You can also download some model import tests here.



27 Comments
I am trying to get into unity an obj file exported from 3dsmax.
Whatever is inside, in this case I have just a generic box, it seems to detect the meshes, but in the end it fails and I get error:
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[UnityEngine.Vector3].get_Item (Int32 index)
GeometryBuffer.PopulateMeshes (UnityEngine.GameObject[] gs, System.Collections.Generic.Dictionary`2 mats) (at Assets/OBJ/src/GeometryBuffer.cs:158)
OBJ.Build () (at Assets/OBJ/src/OBJ.cs:301)
OBJ+c__Iterator0.MoveNext () (at Assets/OBJ/src/OBJ.cs:93)
Thanks in advance if you could give me any hint.
I got it working with no materials export options.
It seems to not cope well with .mtl file generated from max, its empty spaces and lines.
Is it possible to modify the script to get multiple objects instead of one combined mesh?
I had to take down one slash twice in OBJ.cs file to get it to work on files placed in unity project folder
Hi Tomek, apologies for the late response, been busy with the importers and trying to get my site looking right, I will be uploading the full new and improved .OBJ and .DAE importer shortly under MIT, the new OBJ importer deals with textures, bump mapping and I updated some of the material library parts of code to rid some of the material import errors.
Thanks, consider to put after line 104 the following addition:
l=Regex.Replace(l,@”# object”,”o”);//tomekkie ALTERATION – helped to get multiple objects instead of groups
It has helped me to get multiple objects instead of groups in max exported obj. meshes.
Thanks Tomek will look into adding that for the OBJ importer, I overlooked it at first as OBJ’s don’t include transfrom co-ords for each object, hence each objects pivot point will probably be 0,0,0 or the transform.parent pivot point when you break them into groups? I have a little fix in mind for that possibly? Currently the DAE importer imports groups, instances and single meshes with the correct pivot points, it also automatically flip normals, scales meshes to the required max and min scale float settings and converts to Y-up left handed unity co-ordinate space, just looking into automatically centering the geometry or groups of geometries that are offset far from 0,0,0. The importer will also assign materials and shaders depending on data just like the OBJ importer. The OBJ importer supports normal/bump maps, transparency, self-illum and specular – Dae collada importer supports the same bar normal/bump maps as they don’t appear in the collada specification oddly. Both importers load the required textures and merge the alpha channels with diffuse depending on the required shader, one other issue I am trying to resolve is getting back Mip Maps, but I think it’s something to do with import into texture.
Hi Jon,
I’m interested in testing out your run-time import library.
Please let me know if it is available.
Thanks!
This library looks amaizing. I am looking for loading Collada DAE files at runtime on unity3d. where can I get this library? Is it already published?
Thanks in advance
No not online yet, just preparing some bits of my site for launch, but I should be posting version alpha 0.4 by the weekend for all to optimise and add too, so I will mail you as soon as I have uploaded it. Please bear in mind that you will need to extend the code if you wish for it to import animations, bones + IK and physics, but does meshes, uv, normals, textures instances and heirachies without a problem for me at least so far.
Will email you as soon as it’s uploaded, alpha v0.4 with obj-load, dae-load, file browser, auto low poly collision mesh generation, project browser with creation/save/load, and native texture & mesh save/load almost complete:- looking for optimisation and improvements upon upload (of which i’m sure their are lots to make).The license allow users to be able to use the scripts built into their own commercial projects, but ask that the MIT, copyright information remains in each of the scripts and that scripts-source code are not sold for profit or commercial gain.
Thanks for the quick response. I think it will be a good starting point to develop my proyect, I am doing some research over unity3d, and some other game engines to choose one to develop a project. Having this library will be fine and will increase unity3d chances to be the one selected. I know it is a beta and i will have to improve and do some extensions . I will kindly share it with others also if they are worth.
it seems to be very useful. However this unitypackages does not work on Unity 3.3 version.
This error :
Assets/ExampleScenes/runscripts/Example1_ModelLoad.cs(8,25): error CS0103: The name `FileIO’ does not exist in the current context
How can i fix it?
Firstly are you using Unity 3.3 Professional or Unity 3.3 Indie? If you are using Unity 3.3 Pro please contact me and tell me so, the response below is for if you are using Indie.
If using Unity 3.3 Indie (the free version), Plugins do not work or are recognised, and therefore the library that sits in the Plugins folder in your Project window that contains the script FileIO.cs will not be picked up by unity as being an accessible script. The library is mainly intended for Pro users, and to run in Unity Pro. However with adjustments certain features can be used by indie developers depending on there own skills and adjusting the content to work within the constraints of Unity Indie (see below).
For this scenario:-
(although you could go about putting all these scripts into you scene, setting them as singletons attaching them to a empty GO)
Just use the provided BasicLoaders_for_Indy.unitypackage and attach either the DAE or OBJ script to a blank GameObject entering the path for your required model into the path field in the inspector, this should work although I haven’t tested it, (I might query the script linkage to geobuffer and tripoly as a problem but thats for the user to play around with)
Hope this of some help – Jon
PS:- Thanks for the comment, the first feedback I have actually recieved.
using the indie version, I can’t get it to work (texture path), failed to resolve material library:cgBuildingRedBrickWarehouse002B_0.mtl, any hints for the web player resolve path function…when I uncomment….it fails…can get both textures and obj in previuos version, just not normal maps..now I can’t modify or override the resolve path function…any help??? It pulls in the mesh, that path is fine, does not use the resolve path()…
Hi,
can i use the same via web player ? i need to twwen it ?? is it possible ?? please let me know details
Just tried it on my project, worked flawlessly!
Importing DAE files from 3Ds Max actually proved easier than Unity’s FBX importer, which ignores exporter settings…
One little question now:
How does the serializer handle multiple meshes in a model? does it generate a single binary for the whole thing, or does it create a file for each object? If the former, does it retain object separation after deserialization?
Anyway, Great Job!! This is all we could have asked for! Thanks a million!
Cheers
Hi Patrick, apologies for the long wait…
Firstly not sure whether you were aiming for a local file or one on the web, did you resolve this?
If the file is local, I would be interested in a copy of the obj file and the material file location in regards to the obj file, I may possibly have missed something as I am still finding bugs.
If it is a web-based file you may need to do some mods as I haven’t tested this yet, and not at all in Indie, possibly at the top of the script in the Start() function a mod may be required, and as you said in the resolve path function at the very bottom of the OBJ script under the line:-
if (Application.isWebPlayer||basepath.Contains(“http://”))
try adding>> outpath=basepath+filepath;
or >> outpath=basepath+”/”+filepath;
Please let me know how you get on, apologies for any inconvieniance, and I will have more time to work on this around August as i’m currently on a very tight and heavy workload.
Thanks for the response, Jon
if (Application.isWebPlayer||basepath.Contains(“http://”))
Saurabh,
Although I haven’t strictly catered for the web-player just yet, it is possible with some modification. As for the tweening, I believe your talking about skeletal animation in which case this might have to be a later added feature and duly noted but will not be added until a later date when my current work load is clear. Thanks for your interest and please keep in touch.
Gee thanks HarvesteR,
However unfortunatly not quite flawless yet, a new version will be uploaded in June with a few fixes on DAE’s from sketchup (material issues) and possibly some OBJ material lib tweaks, plus the serialisation is not loading back in on the current Alpha 0.4, this is fixed, all this and project save and load which saves and loads everything including scripts, prefabs, imported models under the generated Project GameObject.
The serializer creates a seperate file for each object unless, you have imported as a single or forced a single object when importing, submeshes are still submeshes and contained in the one binary! Please note as I reported above in the Alpha vesion 0.4 there deserialisation code does not work, this was due to an error in understanding how C# works with bits. However all is now fixed and will be released shortly.
edit:- having looked I added submeshes to the serialization after the alpha 0.4 release so, possibly later this month you will get a fully working version.
Beautiful work, just beautiful. I will certainly be donating.
Dear Mr. Jon-Martin,
I found information about your Unity3D Runtime Import Library. It is very interesting for me. In my project I would like to import 3d object in .fbx format. Is it possible now or in near future to import 3D objects in .fbx format by your Unity3D Runtime Import Library? How much your Unity3D Runtime Import Library with importing object in .fbx format will cost? Please answer to my e-mail asap.
Thank you in advance,
Vladimir.
Thanks Vladimir,
For the moment I’m a little busy, finishing the ‘Space’ project and preparing the second alpha version of the import library, it may transpire later in the year (around November) that preparing an FBX importer based upon the code in the DAE importer may not prove so difficult, but do realise as with the dae importer that this would not include animation, or rigging ( If you feel up to it i’m happy for someone else to try this with the existing code ), when this is done I would also release it for free.
However when I’ve done a DAE/FBX importer with animation and bone structure I might need to release it seperately with some charge however that depends on how generous i’m feeling at the time – as I’ve had much demand for this as a feature.
Can not even Compile because of following error:
Assets/plugins/RuntimeImportLib-Alpha0.4/LoadHandlers/3DLoad/core/GeometryBuffer.cs(162,30): error CS0246: The type or namespace name `FaceIndices’ could not be found. Are you missing a using directive or an assembly reference?
Same for line 51 ,62.
Unity 3.4.
Runtime Library version Alpha 0.4
what is the font of the text of this page??? reply please, and thanks for your shared work !!
Firstly apologies to all for not updating the code lately, I’ve finished the project this was started for and suddenly became involved in some heavy duty freelancing project, when I get a moment I will be stripping back what I’ve got and posting it, just caught up trying to keep the wolves from the door, so to speak. Thanks for the offers of support they are gratefully appreciated, I really need to rewrite all the classes to make them more Object Orientated – to make them more re-usable and fit for diversity.
Raul, the font used at the top of this page is…..OFL Goudy and is called through CSS, I used some app at fontsquirrel to convert to the various platform required types ie:- eot, wof, ttf and svg
Getting the same error as above… Which version of Unity did your source work with?
Assets/plugins/RuntimeImportLib-Alpha0.4/LoadHandlers/3DLoad/core/GeometryBuffer.cs(162,30): error CS0246: The type or namespace name `FaceIndices’ could not be found. Are you missing a using directive or an assembly reference?
As we discussed June 22, 2011 you could do some progress in import 3D objects in FBX at the end of this 2011 year. Actually this problem still being interesting for us. Can you please contact us again regard this question.
hi!
found this great jewel! is this running under mobile plattforms android / ios also ?