Embedded Package

Embedded Packages enable bundling supported Creator Toolkit package types (avatars, animations, attachments, and prefab objects) with a space, instead of publishing them to Spatial as standalone items.

Check out the Embedded Packages template for an example of the Embedded Package.

Overview

This article assumes you’re familiar with creating one or more of the Creator Toolkit package types. If you need a refresher, check out the previous articles in this section such as the Space, Avatar or Avatar Animation packages!

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:

Active Package Embedded Section

Embedded packages cannot be granted as item rewards. They will also increase the package size, download size, and loading time, since they're bundled with the space.

How to Use

For every package you want to embed into your space, 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 any string consisting of alphanumeric values.

Warning

Make sure to give your embedded packages unique IDs.

Example

We're going to repurpose existing packages found in the Spatial Starter Template into embedded packages:

  • 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 expand the section and add them one at time using the + button.

Expanded Items

In the above image, 4 embedded packages were added with a value entered in the ID field which is a string value. This value uniquely identifies your embedded package and is used when attempting to use it in your space.

Scripting Examples

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");
SpatialBridge.actorService.localActor.avatar.SetAvatarBody(AssetType.EmbeddedAsset, "1");

Visual Scripting Node Set Avatar Node

Play an Animation

SpatialBridge.actorService.localActor.avatar.PlayEmote(AssetType.EmbeddedAsset, "2");
SpatialBridge.actorService.localActor.avatar.PlayEmote(AssetType.EmbeddedAsset, "2");

Visual Scripting Node Play an Animation

Equip an Attachment

SpatialBridge.actorService.localActor.avatar.EquipAttachment(AssetType.EmbeddedAsset, "3");
SpatialBridge.actorService.localActor.avatar.EquipAttachment(AssetType.EmbeddedAsset, "3");

Visual Scripting Node Equip Attachment

Spawning Prefab Objects

SpatialBridge.spaceContentService.SpawnPrefabObject(AssetType.EmbeddedAsset, "4", new Vector3(0f, 0f, 0f), Quaternion.identity);
SpatialBridge.spaceContentService.SpawnPrefabObject(AssetType.EmbeddedAsset, "4", new Vector3(0f, 0f, 0f), Quaternion.identity);

Visual Scripting Node Spawn Prefab Object