Class PublisherBehaviour<T>
Abstract MonoBehaviour base for components that publish T messages.
Inherited Members
Object.GetEntityId()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Namespace: Unity.SimulationPro.Foundation
Assembly: Unity.SimulationPro.Foundation.dll
Syntax
public abstract class PublisherBehaviour<T> : MonoBehaviour where T : IMessage
Type Parameters
| Name | Description |
|---|---|
| T | The IMessage type this component publishes. |
Remarks
In Start() this component calls FindConnector(Component)
to locate the active IConnector and registers a publisher for Topic.
If no connector is found, a warning is logged and CanPublish remains false.
Properties
CanPublish
Gets a value indicating whether the publisher is ready to send messages.
Declaration
public bool CanPublish { get; }
Property Value
| Type | Description |
|---|---|
| bool |
DefaultTopic
Gets the default topic name used when Topic has not been set.
Declaration
public virtual string DefaultTopic { get; }
Property Value
| Type | Description |
|---|---|
| string |
Publisher
Gets or sets the registered IPublisher for this component.
Available after Start() has run and a connector was found.
Declaration
protected IPublisher Publisher { get; set; }
Property Value
| Type | Description |
|---|---|
| IPublisher |
Topic
Gets or sets the topic name this component publishes to. Defaults to DefaultTopic if not set.
Declaration
public string Topic { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Publish(T)
Publishes a message on the registered topic.
Declaration
public virtual void Publish(T msg)
Parameters
| Type | Name | Description |
|---|---|---|
| T | msg | The message instance. |
Start()
Start.
Declaration
protected virtual void Start()