言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

UnityEvent<T0>

Namespace: UnityEngine.Events

/

Inherits from: Events.UnityEventBase

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

引数1つのUnityEvent

ジェネリックのUnityEvent型を使用したい場合は、クラスをオーバーライドする必要があります

#pragma strict

class MyIntEvent extends UnityEvent.<int> {}

var m_MyEvent : MyIntEvent;

function Start ()
{
	if (m_MyEvent == null)
		m_MyEvent = new MyIntEvent ();

	m_MyEvent.AddListener (Ping);
}

function Update () 
{
	if (Input.anyKeyDown && m_MyEvent != null)
	{
		m_MyEvent.Invoke (5);
	}
}

function Ping (i: int)
{
	Debug.Log ("Ping" + i);
}
no example available in C#
no example available in Boo

Inherited members

Functions

GetPersistentEventCount 登録されている永続的なリスナーの数を取得します
GetPersistentMethodName インデックスから対象のリスナーのメソッド名を取得します
GetPersistentTarget インデックスから対象のリスナーのコンポーネントを取得します
RemoveAllListeners イベントから全てのリスナーを削除します
SetPersistentListenerState 永続的なリスナーの実行状態を変更します

Static Functions

GetValidMethodInfo オブジェクト、関数名、引数タイプのリストからマッチするメソッドを探します