Our Unity connector differs from the other connectors described in our User Guide as it's only really meant for use by software developers. It doesn't have an elaborate UI, but it offers convenience methods to send and receive data.
In addition to this page, you should also take a look at our .NET SDK section.
Check out our dedicated tutorials on Unity (opens new window)!
# Getting Started
Before using this connector, you'll need to follow our standard setup instructions to install Speckle Manager and add a Speckle account. After this, you can proceed to clone the Speckle Unity repository on GitHub (opens new window).
The repo contains a sample scene named
SpecklePlayground that shows how to send and receive data from your default account.
To install the connector into your own Unity project (rather than using sample project), open the Package Manager (
Windows -> Package Manager)
and select Add Package from git URL.
Paste in the following URL
Once the package has installed, you must follow the steps in Project Setup inorder to be able to successfully build your project.
# Editor Time Sending and Receiving
To receive data directly from the editor, just add the
SpeckleManager.cs script to a GameObject, in the inspector you'll now be able to select accounts, streams, branches and commits.
Please note this feature is in early release and might be a bit unstable.
# Game Time Sending and Receiving
Sending and receiving supports either flat and nested structures (such as Grasshopper tress and Dynamo nested lists).
var receiver = myGameObject.AddComponent<Receiver>(); receiver.Init(streamId); receiver.Receive();
Init() method accepts additional optional arguments to use different accounts, automatically receive updates, delete the old objects, report progress and errors etc. Please check the source code (opens new window) for a complete list.
var sender = myGameObject.AddComponent<Sender>(); sender.Send(streamId, objs);
Send() method accepts additional optional arguments to use different accounts, report progress and errors etc. Please check the source code (opens new window) for a complete list.
# Supported Elements
Geometry alone isn't much fun, that's why we've made it easy to also transfer BIM and custom data with your objects.
When receiving data, a
SpeckleProperties component is attached to each object. Inside it there is a
Data that contains all the metadata coming from Speckle. This works similarly when sending data; if any objects have a
SpeckleProperties component attached to them, it will be used.
We have included basic material support in Speckle and in some of our connectors.
When receiving, the Unity connectors first checks if a shader exists in the scene that matches the incoming object's material by name. If a match cannot be found, Speckle will try to create a basic material with the same color and transparency. If an incoming object has no materials set, a default material will be applied.
# Project Setup
In order to sucessfully build a project using the Unity Connector, please ensure the following:
- Set the project architecture to
Diffuseshaders in project settings. To do so, just add them in
Project Settings → Graphics → Built-in Shader Settings → Always Included shaders.
Note that these steps have already been applied to the Speckle Playground sample project.