# SendMessage

> Calls the method named methodName on every MonoBehaviour in this game object.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## SendMessage(string, Object)

Calls the method named methodName on every [MonoBehaviour](/engine/6000.0/script-reference/unityengine/monobehaviour.md) in this game object.

```csharp
public void SendMessage(string methodName, object value)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the method to call.**** (\[Object]\(https\://learn.microsoft.com/dotnet/api/system.object)): Optional parameter for the method.

### Remarks

The receiving method can choose to ignore the argument by having zero arguments. If options is set to [SendMessageOptions.RequireReceiver](/engine/6000.0/script-reference/unityengine/sendmessageoptions/requirereceiver.md) an error is printed when the message is not picked up by any component.

Note that messages will not be sent to inactive objects (ie, those that have been deactivated in the editor or with the [GameObject.SetActive](/engine/6000.0/script-reference/unityengine/gameobject/setactive.md) function).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        /// Calls the function ApplyDamage with a value of 5
        SendMessage("ApplyDamage", 5.0);
    }

    // Every script attached to the game object
    // that has a ApplyDamage function will be called.
    void ApplyDamage(float damage)
    {
        print(damage);
    }
}
```

## SendMessage(string)

Calls the method named methodName on every [MonoBehaviour](/engine/6000.0/script-reference/unityengine/monobehaviour.md) in this game object.

```csharp
public void SendMessage(string methodName)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the method to call.

### Remarks

The receiving method can choose to ignore the argument by having zero arguments. If options is set to [SendMessageOptions.RequireReceiver](/engine/6000.0/script-reference/unityengine/sendmessageoptions/requirereceiver.md) an error is printed when the message is not picked up by any component.

Note that messages will not be sent to inactive objects (ie, those that have been deactivated in the editor or with the [GameObject.SetActive](/engine/6000.0/script-reference/unityengine/gameobject/setactive.md) function).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        /// Calls the function ApplyDamage with a value of 5
        SendMessage("ApplyDamage", 5.0);
    }

    // Every script attached to the game object
    // that has a ApplyDamage function will be called.
    void ApplyDamage(float damage)
    {
        print(damage);
    }
}
```

## SendMessage(string, Object, SendMessageOptions)

Calls the method named methodName on every [MonoBehaviour](/engine/6000.0/script-reference/unityengine/monobehaviour.md) in this game object.

```csharp
public void SendMessage(string methodName, object value, SendMessageOptions options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the method to call.**** (\[Object]\(https\://learn.microsoft.com/dotnet/api/system.object)): Optional parameter for the method.**** (\[SendMessageOptions]\(/engine/6000.0/script-reference/unityengine/sendmessageoptions)): Should an error be raised if the target object doesn't implement the method for the message?

### Remarks

The receiving method can choose to ignore the argument by having zero arguments. If options is set to [SendMessageOptions.RequireReceiver](/engine/6000.0/script-reference/unityengine/sendmessageoptions/requirereceiver.md) an error is printed when the message is not picked up by any component.

Note that messages will not be sent to inactive objects (ie, those that have been deactivated in the editor or with the [GameObject.SetActive](/engine/6000.0/script-reference/unityengine/gameobject/setactive.md) function).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        /// Calls the function ApplyDamage with a value of 5
        SendMessage("ApplyDamage", 5.0);
    }

    // Every script attached to the game object
    // that has a ApplyDamage function will be called.
    void ApplyDamage(float damage)
    {
        print(damage);
    }
}
```

## SendMessage(string, SendMessageOptions)

Calls the method named methodName on every [MonoBehaviour](/engine/6000.0/script-reference/unityengine/monobehaviour.md) in this game object.

```csharp
public void SendMessage(string methodName, SendMessageOptions options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the method to call.**** (\[SendMessageOptions]\(/engine/6000.0/script-reference/unityengine/sendmessageoptions)): Should an error be raised if the target object doesn't implement the method for the message?

### Remarks

The receiving method can choose to ignore the argument by having zero arguments. If options is set to [SendMessageOptions.RequireReceiver](/engine/6000.0/script-reference/unityengine/sendmessageoptions/requirereceiver.md) an error is printed when the message is not picked up by any component.

Note that messages will not be sent to inactive objects (ie, those that have been deactivated in the editor or with the [GameObject.SetActive](/engine/6000.0/script-reference/unityengine/gameobject/setactive.md) function).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        /// Calls the function ApplyDamage with a value of 5
        SendMessage("ApplyDamage", 5.0);
    }

    // Every script attached to the game object
    // that has a ApplyDamage function will be called.
    void ApplyDamage(float damage)
    {
        print(damage);
    }
}
```
