Class SpeckleUnityManager
Manages the stream interactions for a single user in the scene and exposes parameters that control the output of the stream conversion.
Inheritance
Namespace: SpeckleUnity
Assembly: cs.temp.dll.dll
Syntax
public class SpeckleUnityManager : MonoBehaviour, ISpeckleInitializer
Fields
lineMaterial
Assigns to the LineRenderer
s of every line, curve or polyline object for every stream handled by this manager.
Declaration
public Material lineMaterial
Field Value
Type | Description |
---|---|
Material |
loggedInUser
A cached reference to the current logged in user.
Declaration
public User loggedInUser
Field Value
Type | Description |
---|---|
User |
meshMaterial
Assigns to the MeshRenderer
s of every brep or mesh object for every stream handled by this manager.
Declaration
public Material meshMaterial
Field Value
Type | Description |
---|---|
Material |
onStartBehaviour
Controls how the RunStartBehaviourAsync ()
method executes.
Declaration
public StartMode onStartBehaviour
Field Value
Type | Description |
---|---|
StartMode |
onUpdateProgress
A UnityEvent
that is invoked each frame a stream update is progressed, including when it's initialised, for user code to
respond to that event. Passes some helpful data to inform that custom response including the percentage progress.
Declaration
protected SpeckleUnityUpdateEvent onUpdateProgress
Field Value
Type | Description |
---|---|
SpeckleUnityUpdateEvent |
pointMaterial
Assigns to the LineRenderer
s of every point object for every stream handled by this manager.
Declaration
public Material pointMaterial
Field Value
Type | Description |
---|---|
Material |
receivers
A list of all the SpeckleUnityReceivers
this manager controls. Intended to only be directly editable via
the inspector. During runtime you should make use of the RemoveReceiver ()
or AddReceiver ()
methods.
Declaration
protected List<SpeckleUnityReceiver> receivers
Field Value
Type | Description |
---|---|
System.Collections.Generic.List<SpeckleUnityReceiver> |
renderingRule
An optional rendering rule to inject into the stream update process which defines how the stream looks in the scene.
Declaration
public RenderingRule renderingRule
Field Value
Type | Description |
---|---|
RenderingRule |
scaleFactor
A value for easily setting the static Conversions.scaleFactor
value via the inspector.
This class assigs the value once on Start ()
. Default value is 0.001 because it's assuming
that the stream was modelled in milimeters and needs to be scaled to
Declaration
protected double scaleFactor
Field Value
Type | Description |
---|---|
System.Double |
serverUrl
The server to send / receive streams from and authenticate against. Changing this value during
runtime requires calling InitializeAllClients ()
again.
Declaration
protected string serverUrl
Field Value
Type | Description |
---|---|
System.String |
spawnSpeed
Speed value to allow for instantiation to happen gradually over many frames in case of performance issues with large streams that get initialized / updated.
Declaration
public SpawnSpeed spawnSpeed
Field Value
Type | Description |
---|---|
SpawnSpeed |
startLoginEmail
The email to login with on start if onStartBehaviour
is set to at least JustLogin
.
Declaration
public string startLoginEmail
Field Value
Type | Description |
---|---|
System.String |
startLoginPassword
The password to login with on start if onStartBehaviour
is set to at least JustLogin
.
Declaration
public string startLoginPassword
Field Value
Type | Description |
---|---|
System.String |
Properties
ReceiverCount
How many receivers are currently on this manager. Includes both active and inactive receivers.
Declaration
public int ReceiverCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
AddReceiverAsync(String, Transform, Boolean)
Creates a new receiver to be managed by this manager instance.
Declaration
public virtual Task AddReceiverAsync(string streamID, Transform streamRoot = null, bool initialiseOnCreation = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | streamID | The ID of the stream to receive. Authentication will be done using the |
Transform | streamRoot | Optionally, you can provide a |
System.Boolean | initialiseOnCreation | Optionally, the stream can have its |
Returns
Type | Description |
---|---|
Task |
ClearReceivers()
Calls RemoveReceiver (int)
on all receivers on this manager instance.
Declaration
public virtual void ClearReceivers()
GetAllProjectMetaDataForUserAsync(Action<Project[]>)
Exposed method for users to call when trying to download the meta data of the Projects the current logged in user is able to access.
Declaration
public virtual Task GetAllProjectMetaDataForUserAsync(Action<Project[]> callBack)
Parameters
Type | Name | Description |
---|---|---|
Action<Project[]> | callBack | A method callback which takes a |
Returns
Type | Description |
---|---|
Task | An async Task which can be awaited with a coroutine or just ignored. |
Remarks
If download was successful, the resulting array is passed back. If failed, null
is passed. Need to be using the SpeckleCore
namespace to access this type.
GetAllStreamMetaDataForUserAsync(Action<SpeckleStream[]>)
Exposed method for users to call when trying to download the meta data of the Streams the current logged in user is able to access. Use this to get the IDs of the streams you would later want to start receiving or use the rest of the data to populate your UI with data describing the Streams that are available.
Declaration
public virtual Task GetAllStreamMetaDataForUserAsync(Action<SpeckleStream[]> callBack)
Parameters
Type | Name | Description |
---|---|---|
Action<SpeckleStream[]> | callBack | A method callback which takes a |
Returns
Type | Description |
---|---|
Task |
Remarks
If download was successful, the resulting array is passed back. If failed, null
is passed. Need to be using the SpeckleCore
namespace to access this type.
GetBoundsForAllReceivedStreams()
Creates a bounding box that tightly encapsulates all objects in all current streams.
Declaration
public virtual Bounds GetBoundsForAllReceivedStreams()
Returns
Type | Description |
---|---|
Bounds | A bounding box value encapsulating all stream objects in the scene. |
GetCurrentReceivedStreamMetaData()
Get a SpeckleStream
object for each receiver.
Declaration
public virtual SpeckleStream[] GetCurrentReceivedStreamMetaData()
Returns
Type | Description |
---|---|
SpeckleStream[] | An array of |
GetNumbersFromStream(Int32)
Declaration
public virtual List<float> GetNumbersFromStream(int receiverIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | receiverIndex |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.Single> |
GetNumbersFromStream(String)
Declaration
public virtual List<float> GetNumbersFromStream(string streamID)
Parameters
Type | Name | Description |
---|---|---|
System.String | streamID |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.Single> |
GetStringsFromStream(Int32)
Declaration
public virtual List<string> GetStringsFromStream(int receiverIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | receiverIndex |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> |
GetStringsFromStream(String)
Declaration
public virtual List<string> GetStringsFromStream(string streamID)
Parameters
Type | Name | Description |
---|---|---|
System.String | streamID |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> |
InitializeAllClientsAsync()
Loops through each receiver and starts each of their initialization coroutines.
Declaration
public virtual Task InitializeAllClientsAsync()
Returns
Type | Description |
---|---|
Task |
LoginAsync(String, String, Action<User>)
Exposed method for users to call when trying to login to a Speckle server via code.
Declaration
public virtual Task LoginAsync(string email, string password, Action<User> callBack)
Parameters
Type | Name | Description |
---|---|---|
System.String | The email of the account you wish to login with. |
|
System.String | password | The corresponding password for the account. |
Action<User> | callBack | A method callback which takes a |
Returns
Type | Description |
---|---|
Task | An async Task which can be awaited with a coroutine or just ignored. |
Remarks
If login was successful, the resulting user object is passed back. If failed, null
is passed. Need to be using the SpeckleCore
namespace to access this type.
Logout()
Sets the loggedInUser
to null and clears all the current receivers.
Declaration
public virtual void Logout()
ReApplyRenderingRule(Int32)
Declaration
public virtual void ReApplyRenderingRule(int receiverIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | receiverIndex |
RemoveReceiver(Int32)
Remove a receiver of a given index in the list on this manager instance. Cleans up all GameObjects associated to that stream as well.
Declaration
public virtual void RemoveReceiver(int receiverIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | receiverIndex | The index to to remove from. |
RemoveReceiver(String)
Remove the first receiver with a matching stream ID on this manager instance. Cleans up all GameObjects associated to that stream as well.
Declaration
public virtual void RemoveReceiver(string streamID)
Parameters
Type | Name | Description |
---|---|---|
System.String | streamID | The ID of the stream to be removed. If no matching ID is found, nothing will happen. |
RemoveReceiver(Transform)
Remove the first receiver with a matching root Transform
on this manager instance. Cleans
up all GameObjects associated to that stream as well.
Declaration
public virtual void RemoveReceiver(Transform streamRoot)
Parameters
Type | Name | Description |
---|---|---|
Transform | streamRoot | The root object of the stream to be removed. If no matching root is found, nothing will happen. |
RunStartBehaviourAsync()
Intended for running additional actions on start depending on the value of the onStartBehaviour
enum.
Declaration
public virtual Task RunStartBehaviourAsync()
Returns
Type | Description |
---|---|
Task | An async |
SetServerUrl(String)
Logs out and assigns a new url to point to as the Speckle server.
Declaration
public virtual void SetServerUrl(string newServerUrl)
Parameters
Type | Name | Description |
---|---|---|
System.String | newServerUrl | The url of the new Speckle server to point to suffixed with "/api/". |
Start()
Initializes Speckle and assigns the scale factor of all geometry. Invokes the RunStartBehaviour ()
coroutine.
Declaration
protected virtual void Start()
TryGetSpeckleObject(GameObject, out SpeckleObject)
Checks through all receivers and looks up their GameObject
to SpeckleObject
dictionaries and outputs
the SpeckleObject
.
Declaration
public virtual bool TryGetSpeckleObject(GameObject gameObjectKey, out SpeckleObject speckleObjectData)
Parameters
Type | Name | Description |
---|---|---|
GameObject | gameObjectKey | The |
SpeckleObject | speckleObjectData | The |
Returns
Type | Description |
---|---|
System.Boolean | Whether or not the lookup was successful. |
Update()
Since there is a weird bug in Unity with web socket responses not being able to invoke coroutines, we check a boolean on each receiver on each frame to simulate that effect.
Declaration
protected virtual void Update()