Search code examples
unity-game-engineriderassetbundle

A lot of 3D model file can freeze Unity editor and Jetbrains Rider


I would like to use a lot of 3D models more than 4000. The folder can be at least 20GB size. When I opened this folder with Unity editor, it freeze my Unity engine and Jetbrains Rider as you thought. However, these models is no reason to be loaded in every time since several models being loaded is determined in dynamic on runtime.

I think I can make use of AssetBundle feature to load these model in dynamic. However, I think that limit assets must be placed in Assets folder to build as asset. That can freeze my editor and Rider. But technically, I think AssetBundle must be able to be build in separately.

How can I solve this problem?


Solution

  • You can indeed use Assetbundles to fix this issue. If you have all your models build into assetbundles you can store the assetbundle file and assetbundle.manifest on a remote server or FTP and just download it at runtime whenever you need the asset. this way the models will never be in your build project and can even be in a seperate unity project, solving your crashing issues on your main project.

    For my answer i'll be assuming you are using Unity's new Assetbundle browser tool and using a Unity version that is higher than 5.6. If you do not have the new Assetbundle browser here are some quick steps to get it:

    • Download the AssetBundle Browser tool from Unity's GitHub
    • Add the downloaded files to your Unity project's /Asset/ folder
    • Go to Window > assetbundle browser
    • a quick tutorial can be found here

    Building the bundles

    The benefit of using assetbundles for this is that, as long as the Unity versions match, they can be build from seperate projects. Therefore i would recommend creating a new empty project and testing how many models you can have in that project without crashing Unity.

    Once you have found that limit create prefabs out of the models, and add them to the Assetbundle browser tool.

    Set the target platform for which you want to build the assetbundles and the compression you want to apply to in the "build" secton of the assetbundle browser tool. once you have done that hit "build" to build your assetbundles.

    Once this process is completed you can take the assetbundle file and assetbundle.manifest and upload them to a seperate server or FTP that the client can connect to at runtime to download the required assetbundle, containing the desired model.

    Since the new Assetbundle browser tool is open source you can also automate the process of uploading the assetbundles directly after they have been build.

    another benefit of this is that the assetbundle browser will detect any shared assets (e.g shaders, scripts) and give you the option you move them into a shared assetbundle that only needs to be downloaded once, and any following assetbundle can call. This way you won't have to keep downloading shared assets.

    Building assetbundles is quite a time consuming task (also depending on the target platform and compression settings) so if you have the resources available you might want to do this on multiple computers at once.