MegaCache Object

Object Cache
The OBJ Cache system in MegaFiers is a basic version of the system found in the full MegaCache Asset. It allows you to import any number of OBJ files as a sequence and then play those back in Unity. Each OBJ file in the sequence can have any number of vertices (up to the limit of Unity of 65535) and the counts can change between files as well as the face count, texture coordinates etc. If the OBJ files have materials then those will be imported as well and the system will combine all the mesh and material data into a single object.

You can then select to use the mesh data as it was imported but that can take a lot of memory depending on how many files were imported, or you can save the data to an optimized Cache file which massively reduces the memory as the system will compress the data for you. If you use a a cache file as the source the system will stream each frame as it is needed so the memory use comes down to a single frames worth of memory instead of all the data. Or you can choose to make a memory based image of the data for even faster streaming of the data, this option also supports the option for using another thread to pre fetch the next frame of data for you.

How to use

Using the system is very simple, go to the GameObject/Create Other/MegaCache menu and select the OBJ Cache option, this will create a new game object in the scene for you with the required components attached. Next you need to set the frame range for OBJ files that you wish to import, so say for example you exported a sequence of 100 frames from your 3d package called Object_0001.obj to Obj_0100.obj then you would set the ‘First’ value to 0 and the ‘Last’ to 100. You have the option to only load every nth frame if you wish to reduce memory use, if you want every frame from the sequence then set skip to 1, otherwise set how many frames you want to skip.

Next you need to set the Format slider so that the system knows how long the sequence number is in the file name, so for our example the Format would be 4 as the numbers are 4 digits long. Next click the Load Frames button, and then select any frame from the sequence you wish to import and click Open. The system will now show a progress bar as it imports the data. When the data has finished importing you should see the first frame of your sequence in your scene.

It may be the object is too big or small, each 3d package uses different scales for its scenes but you can compensate for that by changing the Import Scale value much as you would importing any object into Unity. Another thing to note is different 3d packages use different coordinate systems, if you find your object is flipped on the X axis then check the Adjust Coords option and reimport the frames.

One other thing to note is most OBJ exporters will use world coordinates for the vertex values, so it is good practice to centre your object at 0,0,0 in the 3d package before you export the sequence so that the pivot will be in the right place.

Main Params

Main Params

Data Import

This will open up the params section that has the options for the importing of OBJ sequences.


This will open up the section where you can choose how the data is stored, depending on which Data source you have selected you will see different options in the Data section below.


This will open up the Animation options for the imported data, where you can control the playback speed, looping etc.

Extra Options

Opens up some extra options for the system.

Main Params

Data Import Params


This will set the first frame the system will import from the OBJ sequence.


This will set the last frame the system will import from the OBJ sequence.


You can tell the system to load every nth frame by setting this to a value other than 1, so if you want to load every 4th frame from the sequence then set this to 4. If you want every frame then set it to 1.


This will tell the system how many digits make up the OBJ sequence filenames, fso if your filename is OBJ_0000.obj then you will need to set the format to 4 to say the names uses 4 digits.

Name Split Char

Sometimes you may have numbers in the main part of the obj sequence filename, if so you can force the system to use the character you place here to split the name part from the frame number in the filename, for example if your sequence is say Anim01_0001.obj then you would use the ‘_’ character to tell the system where to split the filename, if you sequence filenames only has digits to describe the frame number then no split char is needed.

Import Scale

You can control the size of the meshes that are imported by adjusting this value.

Adjust Coords

Some OBJ files have different coordinate systems, if you find your mesh is flipped on the x axis try changing this value and reimporting the files.

Build Tangents

If you plan on using shaders which require tangents then you can sk the system to generate tangents for each OBJ file it imports by checking this box, this will obviously increase the memory used by the imported sequence so only turn it on if you really need tangents.

Load Materials

Turn this on to tell the system to import the mtl files if they are present and to create the materials and textures in Unity, again be careful if you OBJ sequence uses unique materials and textures for every obj file then this could create a lot of assets. The system will do its best to check for duplicates and remove them.

Load Frames

Click this button to open the file select dialog, select any file from the sequence you wish to import, it does matter which frame it is.

Clear Stored Meshes

If you have imported meshes then this button will appear, it is an indication that you have imported meshes attached to the object, if you have created a cache file or an image then you no longer need the meshes so click the button to delete them all and free up the memory used.

Data Import

Data Params

Data Source

Depending on the Data Source you select you will different options in this param section. You have a choice of 3 data sources. Mesh, Image or File. Mesh is the raw Unity Mesh data as it was generated during the import process. Playback of Mesh data is amazingly fast as it is just changing a mesh pointer but you have the overhead of uncompressed mesh data, if your sequences are not long then there is no problem using Mesh data as your source but keep an eye on your memory usage. If it gets too high then you may want to either create a Cache File or an Image. An Image is basically just a cache file stored in memory so again playback is fast and you can use the pre load option if you have more than one thread to speed it up. Memory use for image and cache files is about 1/3 of that of mesh data. File data source will stream the data from a cache file as it is needed, this will result in virtually no memory use and is only a little slower than image for mesh update. Note cache files can not currently be used in Webplayer builds.

Mesh Data Params

Save Uvs

Check this to have the uv data saved to the cache or image files.

Save Normals

Check this to have the normal data saved to the cache or image file.

Save Tangents

Check this to have the tangent data saved to the cache or image file.

Optimize Data

Checking this will tell the system to compress and optimize the mesh data in the cache files, this will result in a lot less memory being used at the cost of slightly slower playback and a little in accuracy.

Save MegaCache File

Click this button to save the data to a MegaCache mgc file.

Create Image

Click this button will make a memory image of the OBJ sequence data.


This section will show some stats on the current frame of data as well as the memory use.

File Data

File Data Params


Shows the filename for the current cache file being used.

Select MegaCache File

Clicking this allows you to select the cache file to be used by the system.


This section will show some stats on the current frame of data as well as the memory use.


Image Data Params


If you are building for a system that supports threading then this option will appear, it allows you to use another thread to fetch the next frame of data making the playback faster.

Delete Image

This will delete the image and free its memory.


This section will show some stats on the current frame of data as well as the memory use.


Animation Params


The current frame number of the sequence, if the Animate option is off then you can scrub this value to playback the sequence.


If you want your sequence to animate in play mode check this box, the system will then update the frame number for you based on the time and fps settings and will loop the animation using the value set in the loop mode below.


The current time of the animation playback, if Animation is on you can scrub this value to playback the animation.


The fps for the sequence, you should set this to the same value as the 3d editor you exported your sequence from to get the correct length of the animation playback


You can alter the speed of the animation playback by changing this value.

Loop Mode

You can select the loop mode for the animation from loop, ping pong or clamp.

Extra Params

Show Normals

Checking this box will tell the system to display the normals for the mesh.

Normal Length

The length of the normal that will be shown.


This video shows the Object cache system playing back a fluids simulation as well as a fracturing object animation.
MegaCache Teaser

This video shows the worfklow of exporting a sequence of OBJ files from a 3d package, in this case 3ds Max, and then importing them into Unity using the MegaCache OBJ system.
Workflow Video