ゲームオブジェクトまたはその子にあたるゲームオブジェクトのすべての MonoBehaviour から methodName という名のメソッドを呼び出します
受信側のメソッドはパラメーターを 0 個にすることで parameter を無視するように選択できます
options が SendMessageOptions.RequireReceiver に設定した場合、コンポーネントに該当するメソッドが存在しない場合はエラーが発生します。
/// Calls the function ApplyDamage with a value of 5
gameObject.BroadcastMessage ("ApplyDamage", 5.0);
// Every script attached to the game object and all its children
// that has a ApplyDamage function will be called.
function ApplyDamage (damage : float) {
print (damage);
}
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void ApplyDamage(float damage) { print(damage); } void Example() { gameObject.BroadcastMessage("ApplyDamage", 5.0F); } }