Getting Started

Introduction

Installation

Project Configuration

Testing in Your Sandbox

Samples & Examples

Core Concepts & Glossary

Package Types

Spaces & Space Templates

Custom Avatars

Custom Avatar Animations

Avatar Attachments

Custom Prefab Objects

Embedded Packages

Drivable Vehicles

Scene Setup

Testing In Unity vs Sandbox

Controlling the Camera

Custom Collision, Layers, and Tags

Audio Mixers and Groups

Key Differences from Standard Unity3D development

Economy

Quests and Rewards

Economy Overview

Monetization

Using Embedded Packages


<aside> ⚠️ Embedded packages cannot be granted as rewards and count towards the maximum package upload size (500 MB)

</aside>

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.

active_package_embedded_section.png

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.

<aside> ⚠️ Be sure your embedded packages are given UNIQUE ids.

</aside>

An Example

We're going to repurpose existing packages found in the Spatial SDK's Examples folders:

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.

Untitled

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

Untitled

Play an Animation

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

Visual Scripting Node

Untitled

Equip an Attachment

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

Visual Scripting Node

Untitled

Spawning Prefab Objects

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

Visual Scripting Node

Untitled

<aside> 🗒️ When spawning prefab objects, you’ll need to manage their lifecycle; there’s currently no API available for removing them from the scene. In addition, the next time you load the space any previously spawned prefab objects will be respawned.

</aside>

2024-02-14 17-16-38.mp4

Check out the Embedded Packages sample available in our Samples & Examples section.


← Previous

Custom Prefab Objects

Next →

Drivable Vehicles