• Manual
  • Scripting API
Show / Hide Table of Contents
  • SpeckleUnity
    • ColorByType
    • ColorKey
    • Conversions
    • RenderingRule
    • SpawnSpeed
    • SpeckleUnityClient
    • SpeckleUnityGeometry
    • SpeckleUnityManager
    • SpeckleUnityMesh
    • SpeckleUnityNumber
    • SpeckleUnityObject
    • SpeckleUnityPoint
    • SpeckleUnityPolyline
    • SpeckleUnityReceiver
    • SpeckleUnitySender
    • SpeckleUnityUpdate
    • SpeckleUnityUpdateEvent
    • SpeckleUnityValueChange
    • StartMode
    • UpdateType
    • WSMessageData
    • WSMessageDataArgs
  • SpeckleUnity.CustomEditors
    • SpeckleUnityMenus
  • SpeckleUnity.Tests
    • AsyncTest
    • SpeckleUnityManagerTests
    • TestInput

Class SpeckleUnityReceiver

A SpeckleUnityClient specialised in receiving streams and updating the scene to reflect any updates made to the stream. Made serializable so that it would render in the inspector along with its exposed fields.

Inheritance
System.Object
SpeckleUnityClient
SpeckleUnityReceiver
Inherited Members
SpeckleUnityClient.manager
SpeckleUnityClient.client
SpeckleUnityClient.streamID
SpeckleUnityClient.RegisterClient()
SpeckleUnityClient.UnregisterClient()
SpeckleUnityClient.ClientOnReady(Object, SpeckleEventArgs)
SpeckleUnityClient.ClientOnLogData(Object, SpeckleEventArgs)
SpeckleUnityClient.ClientOnError(Object, SpeckleEventArgs)
Namespace: SpeckleUnity
Assembly: cs.temp.dll.dll
Syntax
public class SpeckleUnityReceiver : SpeckleUnityClient

Constructors

SpeckleUnityReceiver(String, Transform)

Creates an uninitialized instance of a SpeckleUnityReceiver.

Declaration
public SpeckleUnityReceiver(string streamID, Transform streamRoot = null)
Parameters
Type Name Description
System.String streamID

The stream ID to be received.

Transform streamRoot

An optional root object for the stream to be spawnted under.

Fields

deserializedStreamObjects

A list containing all the Speckle objects from the stream AFTER they had been converted into native Unity objects.

Declaration
protected List<object> deserializedStreamObjects
Field Value
Type Description
System.Collections.Generic.List<System.Object>

layerLookup

Key value pairs of SpeckleCore Layers and Unity Transforms to help with reconstructing the Stream layer heirarchy within the scene heirarchy.

Declaration
protected Dictionary<Layer, Transform> layerLookup
Field Value
Type Description
System.Collections.Generic.Dictionary<Layer, Transform>

messageContent

String used to help with the coroutine workaround. Is set to the conent of the web socket event when it is fired for the manager to respond against.

Declaration
protected string messageContent
Field Value
Type Description
System.String

messageReceived

Boolean used to help with the coroutine workaround. Is set to true when the web socket event is fired for the manager to respond against and then immediately set back to false.

Declaration
protected bool messageReceived
Field Value
Type Description
System.Boolean

propertyBlock

Declaration
protected MaterialPropertyBlock propertyBlock
Field Value
Type Description
MaterialPropertyBlock

streamRoot

An optional Transform that can be optionally set in the inspector for the received stream to be spawned under. If left null, a new one will be created and named after the stream ID.

Declaration
public Transform streamRoot
Field Value
Type Description
Transform

Methods

ClientOnWsMessage(Object, SpeckleEventArgs)

Invoked whenever this client is notified of updates to the stream from the server.

Declaration
protected override void ClientOnWsMessage(object source, SpeckleEventArgs e)
Parameters
Type Name Description
System.Object source
SpeckleEventArgs e
Overrides
SpeckleUnityClient.ClientOnWsMessage(Object, SpeckleEventArgs)
Remarks

NOTE: At the time of writing, coroutines can't be invoked via event callbacks for some reason. Until this is resolved, the OnWsMessageCheck () method can't be called directly and instead, the manager instance will check on each frame whether the method needs to be called in response to this method being invoked.

ConstructLayers()

According to the available layers found in the stream, create a heirarchy of transforms with the same names as those layers and map them against their original layer objects in a dictionary.

Declaration
protected virtual void ConstructLayers()

CreateContents()

First constructs the layers for the stream then deserializes the json of all the stream's objects into Unity gameobjects. The speed of this process is determined by SpeckleUnityManager.spawnSpeed.

Declaration
protected virtual Task CreateContents()
Returns
Type Description
Task

An async Task of the new operation.

FindParentInHierarchy(String[])

An algorithm which looks up the layer heirarchy already created in the scene to find the parent Transform of the next layer to create.

Declaration
protected Transform FindParentInHierarchy(string[] parents)
Parameters
Type Name Description
System.String[] parents

An array of strings which contains the names of the parent layers leading up to and including the direct parent of the next layer to create.

Returns
Type Description
Transform

The Transform of the direct parent of the next layer to create a new Transform for.

InitializeClient(SpeckleUnityManager, String, String)

All clients need to be initialized which creates an instance of an internal speckle client object, authenticates against the server and provides a manager object to receive inspector arguments from.

Declaration
public override Task InitializeClient(SpeckleUnityManager manager, string url, string apiToken)
Parameters
Type Name Description
SpeckleUnityManager manager

The manager instance that provides inspector values for this client.

System.String url

The url of the speckle server to connect to.

System.String apiToken

The authentication token of the user to connect as.

Returns
Type Description
Task

An async Task of the new operation.

Overrides
SpeckleUnityClient.InitializeClient(SpeckleUnityManager, String, String)

OnWsMessageCheck()

Checks the content of the web socket message received from the server and invokes the appropriate coroutine for updating the scene locally to represent the latest state of the stream being received.

Declaration
public virtual void OnWsMessageCheck()

PostProcessObject(Object, Int32)

Called on each stream object after it's been deserialized. Checks against what Type the object ended up as and assigns some additional stuff to it including setting geometry objects under the correct layer.

Declaration
public virtual void PostProcessObject(object deserializedStreamObject, int objectIndex)
Parameters
Type Name Description
System.Object deserializedStreamObject

The stream object after it had been converted from json into a native object.

System.Int32 objectIndex

The indext of this stream object to help with placing it in the layer hierarchy.

ReApplyRenderingRule()

Declaration
public virtual void ReApplyRenderingRule()

RemoveContents()

Clean up all gameobjects for the geometry spawned in from the stream including layer objects.

Declaration
public virtual void RemoveContents()

UpdateGlobal()

Coroutine for the global update message for the stream. Simply put, it redownloads the stream data, cleans up everything locally and respawns the whole stream.

Declaration
protected virtual Task UpdateGlobal()
Returns
Type Description
Task

An async Task of the new operation.

Back to top Generated by DocFX