Version: 5.5

Component.SendMessageUpwards

Cambiar al Manual
public void SendMessageUpwards (string methodName, SendMessageOptions options);
public void SendMessageUpwards (string methodName, object value= null, SendMessageOptions options= SendMessageOptions.RequireReceiver);

Parámetros

methodName Nombre del método a llamar.
value Valor de parámetro opcional para el método.
options Debería un error lanzarse si el método no existe en el objeto destino?

Descripción

Llama al método denominado methodName en todos los MonoBehaviour de este juego y en todos los ancestros del behaviour.

The receiving method can choose to ignore the argument by having zero arguments. If the options parameter is set to SendMessageOptions.RequireReceiver an error is printed when the message is not picked up by any component.

Tenga en cuenta que los mensajes no se enviarán a objetos inactivos (es decir, aquellos que se hayan desactivado en el editor o con la función GameObject.SetActive).

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void ApplyDamage(float damage) { print(damage); } void Example() { SendMessageUpwards("ApplyDamage", 5.0F); } }