Features of the Vortex Unity integration requiring Asset Bundles
In order to simplify the use of the Unity integration with Vortex, we unified both workflows from com.cmlabs.vortex.integration and from com.cmlabs.vortex.integration.standalone into the unified com.cmlabs.vortex.integration.unity. Some features of the integration require asset bundles.
In com.cmlabs.vortex.integration integration, Unity was only used as a renderer (meaning, one-way communication between Vortex and Unity), and the workflow was different. Asset bundles needed to be created and were loaded at runtime for each Vortex document. They could be loaded in the generic VortexUnityApp application or in a custom Unity application.
For documentation on features of the integration with asset bundles, consult these pages:
Asset Bundles are ONLY available in Play mode in Unity.
How are Asset Bundles used for these features?
Those features depend on the use of Asset Bundles and prefabs to instantiate the right unity objects at runtime. The principle is always the same.
Vortex objects must be associated with prefabs in Unity. Each Vortex object has a name and is part of the simulation's object hierarchy. A Unity Game Object hierarchy saved as an asset is called a prefab. Those prefabs must be exported into Asset Bundles, which are containers of Unity assets to be loaded at runtime. For any supported features, the Vortex Integration in Unity will look for a corresponding asset bundle containing a corresponding prefab. This prefab will then be instantiated and updated every frame according to the Vortex simulation, depending on what type of extension it is. Generally, any change in the extension's inputs will be reflected in the instantiated Unity GameObject corresponding to it.
Vortex notifies Unity of a feature that uses an asset bundle
The data is coming from an extension in a Vortex document (mechanism, scene, graphics gallery, etc.)
Vortex Integration package in Unity will look for an Asset Bundle, and open it.
The name of the Asset Bundle file is the same as the Vortex document containing the extension. For example, if an Earthworks zone extension is in Terrain.vxmechanism, the asset bundle file should be Terrain.unity3d
The Asset Bundle file should be in the same directory of the Vortex document the extension is coming from.
In the Asset Bundle, the Vortex Integration package in Unity will look for a prefab with a name that matches the extension name
Â
4. The prefab found is instantiated and added to the Unity Scene.
5. At runtime, data from Vortex will be used by the game object instantiated.
Â
Exporting into an Asset Bundle
When you are satisfied with a prefab, you can package it into an asset bundle, along with its related assets (these are the assets referenced by its different Components). A contextual action has been added to do exactly this.
A Unity Asset Bundle is a file that contains Unity assets to be loaded at runtime only (it cannot be edited). They can be loaded by any Unity application, which is a concept similar to how Vortex Studio asset files can be used in any Vortex Studio simulation. The Asset Bundle contains all the prefabs, materials, etc., that are needed.
All features above need a prefab in an Asset Bundle to work. A prefabs will be instantiated according to the Vortex Extension for the feature, and the prefab contains the components necessary for the features. All prefabs for a Vortex Document (*.vxmechanism, *.vxassembly, *.vxscene, or *.vxgraphicgallery) are grouped into an Asset Bundle file (*.unity3d) that has the same name as the Vortex Document.
When creating prefabs for a feature, you need to
Create a folder in Assets with the same name as the Vortex Document containing the Vortex Extension. This folder will contain all the prefabs related to the Vortex document .
Create the prefab according to the feature’s requirement, and put it in the folder. Repeat as many time as needed, for any feature you require, making sure all the data for the prefab (materials, etc.) are in the folder.
Create an Asset Bundle Export Data object in your asset, using the Create->Vortex menu.
The Asset Bundle Export Data is a list of Folders or Prefabs that will be used to create Asset Bundles.
Use the Export Asset Bundles button will export all Asset Bundles described in the export data.
Each element in the list describes an Asset Bundle
Target Object: The object to export can be a Folder or a Prefab only. The name of the AssetBundle is the name of the objet. When a Folder is the target object, all objects in the Folder will be exported to the Asset Bundle. If a single Prefab is the target object, the Asset Bundle will only contain the prefab.
Enable Export: when true, an Asset Bundle will be created
Path: the directory where the Asset Bundle will be created. Entering an absolute path is good, it will be converted to a relative path when exporting. The same asset Bundle can be exported at several locations if needed.
Label: a name or a description that will be used in a future search tool.Â
When the Export Asset Bundles button, for each element in the list, the Folder content (or Prefab) and related assets will be packaged into an asset bundle file, with extension .unity3d. The name of the Asset Bundle will be the name of the target object.
Make sure to place this file in the same folder as its corresponding Vortex asset file, with the same name too.
At this point, your asset bundle should be ready to be tested or used in a simulation.
Â