Class SignalReceiver
Listens for emitted signals and reacts depending on its defined reactions.
Inheritance
Namespace: UnityEngine.Timeline
Syntax
public class SignalReceiver : MonoBehaviour, INotificationReceiver
Methods
AddEmptyReaction(UnityEvent)
Appends a null SignalAsset with a reaction specified by the UnityEvent.
Declaration
public int AddEmptyReaction(UnityEvent reaction)
Parameters
Type | Name | Description |
---|---|---|
UnityEvent | reaction | The new reaction to be appended. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the appended reaction. |
Remarks
Multiple null assets are valid.
AddReaction(SignalAsset, UnityEvent)
Defines a new reaction for a SignalAsset.
Declaration
public void AddReaction(SignalAsset asset, UnityEvent reaction)
Parameters
Type | Name | Description |
---|---|---|
SignalAsset | asset | The SignalAsset for which the reaction is being defined. |
UnityEvent | reaction | The UnityEvent that describes the reaction. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when the asset is null. |
System.ArgumentException | Thrown when the SignalAsset is already registered with this receiver. |
ChangeReactionAtIndex(Int32, UnityEvent)
Replaces the reaction at a specific index with a new UnityEvent.
Declaration
public void ChangeReactionAtIndex(int idx, UnityEvent reaction)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index of the reaction to be replaced. |
UnityEvent | reaction | The replacement reaction. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when the replacement reaction is null. |
ChangeSignalAtIndex(Int32, SignalAsset)
Replaces the SignalAsset associated with a reaction at a specific index.
Declaration
public void ChangeSignalAtIndex(int idx, SignalAsset newKey)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index of the reaction. |
SignalAsset | newKey | The replacement SignalAsset. |
Remarks
The new SignalAsset can be null.
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the replacement SignalAsset is already registered to this SignalReceiver. |
Count()
Returns the count of registered SignalAssets.
Declaration
public int Count()
Returns
Type | Description |
---|---|
System.Int32 |
GetReaction(SignalAsset)
Gets the first UnityEvent associated with a SignalAsset.
Declaration
public UnityEvent GetReaction(SignalAsset key)
Parameters
Type | Name | Description |
---|---|---|
SignalAsset | key | A SignalAsset defining the signal. |
Returns
Type | Description |
---|---|
UnityEvent | Returns the reaction associated with a SignalAsset. Returns null if the signal asset does not exist. |
GetReactionAtIndex(Int32)
Gets the reaction at a specific index.
Declaration
public UnityEvent GetReactionAtIndex(int idx)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index of the reaction. |
Returns
Type | Description |
---|---|
UnityEvent | Returns a reaction. |
GetRegisteredSignals()
Gets a list of all registered SignalAssets.
Declaration
public IEnumerable<SignalAsset> GetRegisteredSignals()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SignalAsset> | Returns a list of SignalAssets. |
GetSignalAssetAtIndex(Int32)
Gets the SignalAsset at a specific index
Declaration
public SignalAsset GetSignalAssetAtIndex(int idx)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index of the SignalAsset. |
Returns
Type | Description |
---|---|
SignalAsset | Returns a SignalAsset. |
OnNotify(Playable, INotification, Object)
Called when a notification is sent.
Declaration
public void OnNotify(Playable origin, INotification notification, object context)
Parameters
Type | Name | Description |
---|---|---|
Playable | origin | |
INotification | notification | |
System.Object | context |
Remove(SignalAsset)
Removes the first occurrence of a SignalAsset.
Declaration
public void Remove(SignalAsset asset)
Parameters
Type | Name | Description |
---|---|---|
SignalAsset | asset | The SignalAsset to be removed. |
RemoveAtIndex(Int32)
Removes the SignalAsset and reaction at a specific index.
Declaration
public void RemoveAtIndex(int idx)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index of the SignalAsset to be removed. |