Unity has a completely automatic AssetAny media or data that can be used in your game or project. An asset may come from a file created outside of Unity, such as a 3D model, an audio file or an image. You can also create some asset types in Unity, such as an Animator Controller, an Audio Mixer or a Render Texture. More info
See in Glossary pipeline. Whenever a source Asset like a .psd or an .fbx file is modified, Unity detects the change and automatically re-imports it. The imported data from the file is subsequently stored by Unity in an internal format.
This arrangement is designed to make the workflow as efficient and flexible as possible for an individual user. However, when working in a team, you may find that other users might keep making changes to Assets, all of which must be imported. Furthermore, Assets must be reimported when you switch between desktop and mobile buildThe process of compiling your project into a format that is ready to run on a specific platform or platforms. More info
See in Glossary target platforms. The switch can therefore take a long time for large projects.
Caching the imported Assets data on the Cache Server drastically reduces the time it takes to import Assets.
Each Asset import is cached based on:
If any of the above change, the Asset is re-imported. Otherwise, it is downloaded from the Cache Server.
When you enable the Cache Server (see How to set up a Cache Server as a user, below), you can even share Asset imports across multiple projects (that is, the work of importing is done on one computer and the results are shared with others).
Note that once the Cache Server is set up, this process is completely automatic, so there are no additional workflow requirements. It will simply reduce the time it takes to import projects without getting in your way.
Setting up the Cache Server couldn’t be easier. All you need to do is check Use Cache Server in the preferences and tell the local computer’s Unity Editor where the Cache Server is.
The Cache Server settings can be found in Unity > Preferences on Mac OS X or Edit > Preferences on Windows and Linux.
To host the Cache Server on your local computer instead of a remote one, set Cache Server Mode to Local.
This setting allows you to easily configure a Cache Server on your local machine. Due to hard drive size limitations, it is recommended you host the Cache Server on a separate computer.
|Cache Server Mode||Select the Cache Server Mode you wish to use. This setting allows you to disable use of the Cache Server, specify a remote server, or set up a Cache Server on your local computer.|
|Disabled (default)||Do not use a Cache Server.|
|Remote||Use a Cache Server hosted on a remote computer.|
|Local||Use a local Cache Server on this computer.|
|Specify the IP address of the remote machine hosting the Cache Server.|
|Use this button to attempt to connect to the remote Cache Server.|
Maximum Cache Size (GB)
|Specify a maximum size in gigabytes for the Cache Server on this computer’s storage. The minimum size is 1GB. The maximum cache size is 200GB. The default is 10GB.|
|Custom cache location||Specify a location on disk to store the cache.|
Check Cache Size
|Click this to find out how much storage the Local Cache Server is using. This operation can take some time to complete if you have a large project. The message “Cache size is unknown” is replaced with the cache size when it has finished running.|
|Clean Cache||Delete the contents of the cache.|
Unity displays the following warning if you have a Local Cache Server with a custom location, and that location becomes unavailable:
Local cache directory does not exist - please check that you can access the cache folder and are able to write to it
Admins need to set up the Cache Server computer that will host the cached Assets.
You need to:
The Cache Server needs to be on a reliable computer with very large storage (much larger than the size of the project itself, as there will be multiple versions of imported resources stored). If the hard disk becomes full the Cache Server could perform slowly.
.cmd scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary must be set up as a service on the server. The Cache Server can be safely killed and restarted at any time, since it uses atomic file operations.
Two Cache Server processes are started by default. The legacy Cache Server works with versions of Unity prior to version 5.0. The new Cache Server works with versions of Unity from 5.0 and up. See Cache Server configuration, below for details on configuring, enabling, and disabling the two different Cache Servers.
If you simply start by executing the script, it launches the legacy Cache Server on port 8125 and the new Cache Server on port 8126. It also creates “cache” and “cache5.0” directories in the same directory as the script, and keep data in there. The cache directories are allowed to grow to up to 50 GB by default. You can configure the size and the location of the data using command line options, like this:
./RunOSX.command --path ~/mycachePath --size 2000000000
./RunOSX.command --path ~/mycachePath --port 8199 --nolegacy
You can configure the Cache Server by using the following command line options:
--portto specify the server port. This only applies to the new Cache Server. The default value is
--pathto specify the path of the cache location. This only applies to the new Cache Server. The default value is
--legacypathto specify the path of the cache location. This only applies to the legacy Cache Server. The default value is
--sizeto specify the maximum cache size in bytes for both Cache Servers. Files that have not been used recently are automatically discarded when the cache size is exceeded.
--nolegacyto stop the legacy Cache Server starting. Otherwise, the legacy Cache Server is started on port
For best performance there must be enough RAM to hold an entire imported project folder. In addition, it is best to have a computer with a fast hard drive and fast Ethernet connection. The hard drive should also have sufficient free space. On the other hand, the Cache Server has very low CPU usage.
One of the main distinctions between the Cache Server and version controlA system for managing file changes. You can use Unity in conjunction with most common version control tools, including Perforce, Git, Mercurial and PlasticSCM. More info
See in Glossary is that its cached data can always be rebuilt locally. It is simply a tool for improving performance. For this reason it doesn’t make sense to use a Cache Server over the Internet. If you have a distributed team, you should place a separate Cache Server in each location.
The Cache Server runs optimally on a Linux or Mac OS X computer. The Windows file system is not particularly well-optimized for how the Cache Server stores data, and problems with file locking on Windows can cause issues that don’t occur on Linux or Mac OS X.
The Cache Server removes Assets that have not been used for a period of time automatically (of course if those Assets are needed again, they are re-created on next usage).
The Cache Server is designed to be transparent to source/version control systems, so you are not restricted to using Unity’s Asset serverLegacy - An asset and version control system with a graphical user interface integrated into Unity. Enables team members to work together on a project on different computers. More info
See in Glossary.
When Unity is about to import an Asset, it generates an MD5 hash of all source data.
For a Texture, this consists of:
If that hash is different from what is stored on the Cache Server, the Asset is reimported. Otherwise the cached version is downloaded. The client Unity Editor only pulls Assets from the server as they are needed - Assets don’t get pushed to each project as they change.
The Cache Server does not handle dependencies. Unity’s Asset pipeline does not deal with the concept of dependencies. It is built in such a way as to avoid dependencies between Assets. The AssetPostprocessor class is a common technique used to customize the Asset importer to fit your needs. For example, you might want to add MeshColliders to some GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary in an .fbx file based on their name or tag.
It is also easy to use
AssetPostprocessor to introduce dependencies. For example you might use data from a text file next to the Asset to add additional componentsA functional part of a GameObject. A GameObject can contain any number of components. Unity has many built-in components, and you can create your own by writing scripts that inherit from MonoBehaviour. More info
See in Glossary to the imported GameObjects. This is not supported in the Cache Server. If you want to use the Cache Server, you have to remove dependency on other Assets in the project folder. Since the Cache Server doesn’t know anything about the dependency in your postprocessor, it does not know that anything has changed, and thus uses an old cached version of the Asset.
In practice there are plenty of ways you can do Asset postprocessing to work well with the Cache Server. You can use:
Modifying Materials that already exist might cause trouble. When using the Cache Server, Unity validates that the references to Materials are maintained, but because no postprocessing calls are invoked, the contents of the Material cannot be changed when a model is imported through the Cache Server. Because of this, you might get different results when importing with and without Cache Server. It is best never to modify Materials that already exist on disk.
There are a few kinds of Asset data which the server doesn’t cache. There isn’t really anything to be gained by caching script files, so the server ignores them. Also, native files used by 3D modelling software (Maya, 3D Max, etc) are converted to FBX using the application itself. The Asset server does not cache the native file nor the intermediate FBX file generated in the import process. However, it is possible to benefit from the server, by exporting files as FBX from the modelling software and then adding those to the Unity project.
Did you find this page useful? Please give it a rating: