Class ConnectorInjector
Discovers and provides the active IConnector for a given scene object.
Inherited Members
Namespace: Unity.SimulationPro.Foundation
Assembly: Unity.SimulationPro.Foundation.dll
Syntax
public static class ConnectorInjector
Remarks
FindConnector(GameObject) walks the transform hierarchy of the supplied object,
checking the object itself, its immediate children, and then each parent in turn, until an
enabled BaseConnectionComponent is found. If none is found on the hierarchy,
GetDefaultConnector() searches the entire scene and caches the result.
The cached default connector is cleared when the active scene changes.
Methods
FindConnector(Component)
Finds the nearest active IConnector relative to the supplied component.
Declaration
public static IConnector FindConnector(Component startPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| Component | startPoint | The component from which to begin the hierarchy search. |
Returns
| Type | Description |
|---|---|
| IConnector | The nearest active IConnector, or the scene-wide default if none is found on the hierarchy. |
FindConnector(GameObject)
Finds the nearest active IConnector by walking the transform hierarchy of the supplied GameObject.
Declaration
public static IConnector FindConnector(GameObject startPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | startPoint | The GameObject from which to begin the hierarchy search. |
Returns
| Type | Description |
|---|---|
| IConnector | The nearest active IConnector, or the scene-wide default connector if none is found on the hierarchy. |
GetDefaultConnector()
Returns the cached default IConnector, discovering it from the scene if necessary.
Declaration
public static IConnector GetDefaultConnector()
Returns
| Type | Description |
|---|---|
| IConnector | The default IConnector, or |
Remarks
When multiple connectors exist in the scene, the one closest to the scene root is preferred. The result is cached until the active scene changes.
SetDefaultConnector(BaseConnectionComponent)
Overrides the default connector using the IConnector obtained from the provided component.
Declaration
public static void SetDefaultConnector(BaseConnectionComponent connection)
Parameters
| Type | Name | Description |
|---|---|---|
| BaseConnectionComponent | connection | The connection component whose connector to use. |
SetDefaultConnector(IConnector)
Overrides the default connector with the provided IConnector instance.
Declaration
public static void SetDefaultConnector(IConnector connection)
Parameters
| Type | Name | Description |
|---|---|---|
| IConnector | connection | The connector to use as the scene default. |