How to Use Asset Bundles in the Unified Integration
To ease the transition from the Vortex Unity Asset Bundle workflow to the Vortex Unity scene workflow, some features were made available in the com.cm-labs.vortex.integration.unity package that allows using existing asset bundles, made for the Asset Bundle workflow (from com.cm-labs.vortex.integration package). Asset bundles for a Vortex scene can be used as is, or through an associated Vortex-Unity scene.
Using asset bundles in this way can be enabled or disabled on a per-scene basis, and finer control is also available on a per-object basis.
Below are described the different use cases and existing features to help unify your content in a Unity project with the full integration.
See https://cm-labs.atlassian.net/wiki/spaces/VSD2407/pages/776528106/Features+of+the+Vortex+Unity+integration+requiring+Asset+Bundles#Exporting-into-an-Asset-Bundle to have a simple way to create, maintain and export Asset Bundles in your Unity project.
Using Asset Bundles exclusively
First of all, it is possible to simply reuse existing asset bundle content from the Asset Bundle Integration in the Unified Integration. All you need are the Vortex assets and their corresponding asset bundles, and to prepare your Unity project for using one (or more) non-associated Vortex scenes.
Preparing your Unity project with the Asset Bundle Scene
To run such content in a simulator using your custom Unity application with the Unified package (com.cm-labs.vortex.integration.unity), you need to make sure that your Vortex scene doesn't have any Unity scene associated with it.
In this case, when asset bundles are loaded and their prefabs are instantiated at runtime, a specific Unity scene is loaded and the asset bundle prefabs are instantiated in it. This default scene is located in the Resources of the integration package: Packages/com.cmlabs.vortex.integration.unity/Resources/Scenes/VortexAssetBundleScene
To use it in your Unity application, this scene must be added to the Unity project’s Build Settings (“Scenes in Build“ list). This can be easily done through this convenient Vortex menu button:
When this is done, you should see the scene appear in the list of scenes of the Build Settings:
Override the default Asset Bundle Scene with a different one
The default scene mentioned above is identical to the scene that was used in the Asset Bundle integration’s VortexUnityApp application. If you wish to use a different one (for instance, to set different lighting settings), you should:
Create a different empty scene anywhere in your project but with the same scene name as the default one (VortexAssetBundleScene.unity).
Then, manually replace the default scene in the Build Settings scene list with this new scene.
Testing and launching your scene with asset bundles
After this is done you can launch your scene in the typical ways:
Unity Editor + Vortex Player Window: You can launch your scene in the Unity Editor by entering Play Mode, which will open the Vortex Player Window, and by loading the Vortex scene through the Browser tab. You can technically do this from any open Unity scene, but to reproduce the end result, the scene VortexAssetBundleScene.unity should be opened first in the Editor. This Editor workflow is based on the workflow from com.cmlabs.vortex.integration package, which entirely relied on asset bundles.
Distributed Simulation using custom Unity application: See this guide: Launch a Distributed Simulator using Vortex Director
Using Asset Bundles in an associated Vortex-Unity Scene
Asset Bundles can also be used in an existing Unity scene associated with a Vortex scene. By default, they are not used. But, if needed, this can be changed by toggling the “Use Asset Bundle Prefabs“ parameter of the Vortex Scene component, which is found in the Inspector panel when selecting the Vortex Scene game object.
When this parameter is enabled, all Vortex documents that are part of this scene and that have a corresponding asset bundle will be used at runtime.
Press the “Sync with Vortex Scene document“ button to update the Unity scene. If a Vortex object (like a mechanism) with an asset bundle is present in the Unity scene hierarchy, it will be removed from it when pressing this button. The asset bundle prefab for this mechanism will then be loaded when entering Play mode.
Turning the parameter off and pressing the Sync button again will synchronize the scene as it would when loading the Unity scene or associating a scene from the Vortex menu, populating the scene with any necessary objects (with placeholder objects or from prefabs, if defined).
Selecting asset bundle prefabs to use in a scene
The Vortex Scene component also displays a list of asset bundles that can be used in this scene. From this list, each asset bundle can be toggled on or off individually to specify which should be used at runtime. When not checked, objects in the scene will be used, as usual with the main workflow.
The “Select all“ and “Deselect all“ buttons are also available under the list in cases where fine-tuning is not necessary.
After a selection is done, the “Sync with Vortex Scene document” button must always be pressed and the scene will be updated to reflect the selection of asset bundle prefabs.
Then, save your Vortex-Unity scene as you would for any associated scene.
Testing and launching your scene with asset bundles
After this is done you can launch your scene in the typical ways:
Unity Editor + Vortex Player Window: You can launch your scene in the Unity Editor by entering Play Mode when your associated Unity scene is open. If any are selected, asset bundles will be loaded and their prefabs will be instantiated. This is the main workflow when testing a scene in the Editor for this integration.
Distributed Simulation using custom Unity application: See this guide: Launch a Distributed Simulator using Vortex Director