MessageBusGameObjectExtensions SubcribeToMessage T  Method DH.Messaging Documentation

[This is preliminary documentation and is subject to change.]

Subscribe to messages with type T and supplied message key

Namespace: (Default Namespace)
Assembly: DH.Messaging.Extensions (in DH.Messaging.Extensions.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

public static MessageBusSubscriber SubcribeToMessage<T>(
	this GameObject gameObject,
	string messageKey
)

Parameters

gameObject
Type: GameObject
GameObject to attach the subscriber to
messageKey
Type: OnlineSystem String
Unique message identification key
Type Parameters

T
Type of messages to be expected by the subscriber

Return Value

Type: MessageBusSubscriber
MessageBusSubscriber Component

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type GameObject. When you use instance method syntax to call this method, omit the first parameter. For more information, see OnlineExtension Methods (Visual Basic) or OnlineExtension Methods (C# Programming Guide).
Remarks

Automatically Creates a MessageBusSubscriber component and subscription with the default options if one does not already exist. The subscriber is returned, allowing you to access the subscription and set the options
Examples

Example of subscribing to a message of type float using this extension method
var subscriber = gameObject.SubscribeToMessage<float>("playerSpeed");
See Also