Aller au contenu

Asset bundles

!

The Asset Bundle containing a movie scene projecting a movie.

Unity's Assets Bundles are containers of Unity objects in the form of files. The idea of these Asset Bundles is to store data that can be loaded at any time into a Unity application.

Asset Bundle scene / object

VRmaze supports these Assets Bundles to allow loading of third party data prepared in a Unity editor and thus optimized for operation. VRmaze offers mainly 2 types of 3D objects to support a wide variety of objects that can be integrated in an Asset Bundle. It is thus possible to load a simple object, a Unity prefab or a complete scene.

Prefab in an Asset Bundle

A prefab loaded via an Asset Bundle will only represent a single entity in the protocol tree, even if the prefab contains thousands of visual objects.

Scene in an Asset Bundle

To use a scene contained in an Asset Bundle, we use the 3d Unity Asset Bundle Scene object from VRmaze.

Setting up a scene

Unlike a Unity prefab, the loaded scene cannot be moved.

Light textures in a scene

The light textures are integrated into the scene in the Asset Bundle. In this use case, you should use the same version of Unity as the VRmaze viewer.

Unity version

The version of Unity used is 2020.2.1f1. It is possible to use another version close to this one for the creation of Assets Bundles, with risks of data loss concerning meshes, mapping coordinates or light textures.

Manifest file

When creating an Assets Bundles file, a manifest file is generated. This manifest file, with the same name as the Asset Bundle file, contains the data information embedded in the Asset Bundle, this allows to find all the names of the embedded data.

Manifest file and protocol archiving

The manifest file, linked to the Asset Bundle is not included in the protocol archive zip file.

Cleaning the asset bundle database

Unity stores the asset bundles previously loaded by name in its own database. If an asset bundle is modified, it is possible that the VRmaze viewer will load the data contained in the Unity database. It is possible to delete this database to be sure to use the latest version of the asset bundle.

VRmaze has a tool to delete this database under the general Clear Asset Bundle Cache menu.

!

The Asset Bundle containing a movie scene showing a movie.

Clearing the cache

Before clearing the cache of Asset Bundles, you should make sure that you do not have any Asset Bundles loaded in VRmaze, in which case the deletion will not work. The best time to clear the cache is just after VRmaze is launched.

Scripts in Asset Bundles

Data about visualization, materials, meshes and hierarchical structures are preserved when creating Assets Bundles. A problem arises when using behaviors (MonoBehaviour). These behaviors are not included in the Asset Bundle only as a reference. While the behaviors provided by Unity are natively supported in VRmaze, user-developed behaviors will not be fully integrated into the Asset Bundle. Only references to the scripts are retained.

Integration of scripts

Scripts must be integrated into the Unity project as .Dll files. Copying these .Dll files to the Plugins folder in the VRmaze installation folder allows for full integration of the scripts or any other computer code needed for the Asset Bundle. A tutorial on how to create a behavior library is available here

Creating an Asset Bundle

Creating a Unity Asset Bundle is a simple procedure. VRmaze comes with a specific folder named UnityReflectExporterProject in the user data folder. This folder contains a sub-folder called Assets\Editor'. Simply copy thisEditor` folder into the Unity project. The Unity editor will then have a new tool for creating all the project's asset bundles.

The creation and use of Assets Bundles has its own documentation section.

Renderer

VRmaze version 2021 uses Unity's "Built-In Render Pipeline" rendering. It is therefore important that the Assets Bundles are created in this version of the renderer (no URP or HDRP). In any other renderer, the geometries will appear pink.

Writing Assets Bundles

Assets Bundles files are created in the AssetBundles folder in the Asset folder of the Unity project. This folder should be copied to the VRmaze user data folder in order to use the Assets Bundles.