Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

UnityEvent<T0,T1>

class in UnityEngine.Events

/

Inherits from: Events.UnityEventBase

Switch to Manual

Description

Two argument version of UnityEvent.

If you wish to use a generic UnityEvent type you must override the class type.

#pragma strict

class My2ArgEvent extends UnityEvent.<int, int> {}

var m_MyEvent : My2ArgEvent;

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

m_MyEvent.AddListener (Ping); }

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

function Ping (i0: int, i1: int) { Debug.Log (i0 + i1); }

Inherited members

Public Functions

GetPersistentEventCountGet the number of registered persistent listeners.
GetPersistentMethodNameGet the target method name of the listener at index index.
GetPersistentTargetGet the target component of the listener at index index.
RemoveAllListenersRemove all listeners from the event.
SetPersistentListenerStateModify the execution state of a persistent listener.

Static Functions

GetValidMethodInfoGiven an object, function name, and a list of argument types; find the method that matches.