Getting Started
Package Types
Scene Setup
Economy
Scripting
Components
Guidelines
Support
Using Embedded Packages
This article assumes you’re familiar with creating one or more of the Creator Toolkit package types. If you aren’t, or need a refresher, check out the previous articles in the Unity Package Types section.
Embedded Packages are a way for creators to bundle supported Creator Toolkit package types (avatars, animations, attachments, and prefab objects) with their spaces without needing to publish them to Spatial and manage through Spatial Studio.
If you've previously published one or more of the supported Creator Toolkit package types, you already understand how to create & set them up. The difference is instead of publishing the package to Spatial and then setting it up through Spatial Studio, you include it in the Embedded Packages section of your space's configuration.
Here’s How
For every package you want to embed, create a new entry in the configuration’s Embedded Packages section. Then, drag your package (most likely a prefab) into the Asset slot and give it an Id. The Id can be an alphanumeric value.
An Example
We're going to repurpose existing packages found in the Spatial SDK's Examples folders:
- the Spatian avatar:
Assets/Examples/Avatar_Spatian/Spatian.prefab
- the Standing Arguing animation:
Assets/Examples/AvatarAnimation_DemoAnimation/Standing Arguing Avatar Animation.prefab
- the Space Gun attachment:
Assets/Examples/AvatarAttachment_Space_Gun/Space_Gun.prefab
- the Boom Box prefab object:
Assets/Examples/PrefabObject_BoomBox/1980s_Boombox.prefab
Your Active Package configuration (in the Spatial Portal window) should be set to the space where these packages will be embedded. Find the Embedded Packages section and either enter a numerical value (the number of packages you're embedding) and press enter or twirl open the section and add them one at time using the + button.
In the above image, 4 embedded packages were added, with a value entered in the Id field which is astring
value. This value uniquely identifies your embedded package and is used when attempting to use it in your space.
C# Snippets
To use these snippets in your own project, replace the id parameter (the string
) with the id of your embedded asset that you assigned in the package configuration.
Change the Player’s Avatar
SpatialBridge.actorService.localActor.avatar.SetAvatarBody(AssetType.EmbeddedAsset, "1");
Visual Scripting Node
Play an Animation
SpatialBridge.actorService.localActor.avatar.PlayEmote(AssetType.EmbeddedAsset, "2");
Visual Scripting Node
Equip an Attachment
SpatialBridge.actorService.localActor.avatar.EquipAttachment(AssetType.EmbeddedAsset, "3");
Visual Scripting Node
Spawning Prefab Objects
SpatialBridge.spaceContentService.SpawnPrefabObject(AssetType.EmbeddedAsset, "4", new Vector3(0f, 0f, 0f), Quaternion.identity);
Visual Scripting Node
Check out the Embedded Packages sample available in our Samples & Examples section.