# Reactions

Kind: Class · Namespace: Sansar.Simulation · Assembly: Sansar.Simulation.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Simulation">Namespace <a href="/scripting/api/sansar.simulation"><code>Sansar.Simulation</code></a></span>
<span>Inherits <a href="/scripting/api/sansar.script/instanceinterface">Sansar.Script.InstanceInterface</a></span>
<span class="api-badge api-since">Added in 41.0.0</span>
</div>

<span id="T:Sansar.Simulation.Reactions"></span>

The Reactions class subscriptions to user reaction events.

```csharp
public class Reactions : Sansar.Script.InstanceInterface
```

## Members at a glance

| Kind | Members |
|---|---|
| **Methods** | [AddReaction](#addreaction) · [AddSystemReaction](#addsystemreaction) · [DisableDefaultReactions](#disabledefaultreactions) · [RemoveReaction](#removereaction) · [SubscribeToReaction](#subscribetoreaction) |

## Methods

### AddReaction

<div class="api-card">
<span id="M:Sansar.Simulation.Reactions.AddReaction(System.String,System.String,Sansar.Simulation.ThumbnailedClusterResource)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 43.2.1</span></div>

```csharp signature
public void AddReaction(
    string reactionType,
    string displayText,
    ThumbnailedClusterResource resource
)
```

Add a new reaction type to all clients

| Parameter | Type | Description |
|---|---|---|
| `reactionType` | [string](https://learn.microsoft.com/dotnet/api/system.string) | A string that gets passed to the callback.  Should be of a form like &#39;Developer.Type&#39; to match the default, e.g. &#39;Sansar.Fire&#39; |
| `displayText` | [string](https://learn.microsoft.com/dotnet/api/system.string) | A short string that appears on the emotes panel |
| `resource` | [ThumbnailedClusterResource](/scripting/api/sansar.simulation/thumbnailedclusterresource) | A cluster source which has a thumbnail defined in inventory. |

</div>

### AddSystemReaction

<div class="api-card">
<span id="M:Sansar.Simulation.Reactions.AddSystemReaction(System.String,System.String,System.String,Sansar.Simulation.ClusterResource)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 43.2.1</span></div>

```csharp signature
public void AddSystemReaction(
    string reactionType,
    string displayText,
    string thumbnailPath,
    ClusterResource resource
)
```

Add a new system default reaction.  Intended for internal use by Sansar

| Parameter | Type | Description |
|---|---|---|
| `reactionType` | [string](https://learn.microsoft.com/dotnet/api/system.string) | A string that gets passed to the callback.  Should be of a form like &#39;Developer.Type&#39; to match the default, e.g. &#39;Sansar.Fire&#39; |
| `displayText` | [string](https://learn.microsoft.com/dotnet/api/system.string) | A short string that appears on the emotes panel |
| `thumbnailPath` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Must be a path to a file included by client.  RUNTIME:/UI/Social/Images/\*.png |
| `resource` | [ClusterResource](/scripting/api/sansar.simulation/clusterresource) | A cluster source that will be passed to the reaction callback. |

</div>

### DisableDefaultReactions

<div class="api-card">
<span id="M:Sansar.Simulation.Reactions.DisableDefaultReactions"></span>
<span id="M:Sansar.Simulation.Reactions.DisableDefaultReactions()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 43.2.1</span></div>

```csharp signature
public void DisableDefaultReactions()
```

Removes all the default reactions from the emote menu, leaving only custom ones.

</div>

### RemoveReaction

<div class="api-card">
<span id="M:Sansar.Simulation.Reactions.RemoveReaction(System.String)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 43.2.1</span></div>

```csharp signature
public void RemoveReaction(string reactionType)
```

Remove the specified global reaction from all clients.

| Parameter | Type | Description |
|---|---|---|
| `reactionType` | [string](https://learn.microsoft.com/dotnet/api/system.string) | A string that gets passed to the callback.  Should be of a form like &#39;Developer.Type&#39; to match the default, e.g. &#39;Sansar.Fire&#39; |

</div>

### SubscribeToReaction

<div class="api-card">
<span id="M:Sansar.Simulation.Reactions.SubscribeToReaction(System.Action{Sansar.Simulation.ReactionData},System.Boolean)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 41.0.0</span></div>

```csharp signature
public Sansar.Script.IEventSubscription SubscribeToReaction(
    Action<ReactionData> callback,
    bool persistent
)
```

Subscribes to Reaction Events.

| Parameter | Type | Description |
|---|---|---|
| `callback` | [Action&lt;ReactionData&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Callback which is executed when the event completes. |
| `persistent` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Optional, set to false to unsubscribe after one event. |

**Returns:** [Sansar.Script.IEventSubscription](/scripting/api/sansar.script/ieventsubscription) — An [`IEventSubscription`](/scripting/api/sansar.script/ieventsubscription) that can be used to cancel the subscription.

</div>


## Used in examples

- [ReactionsExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ReactionsExample.cs)
- [ScriptLibrary/Scene/Reaction.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/Reaction.cs)

<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>