Skip to content
zilch edited this page Sep 19, 2020 · 2 revisions

Example

1. Basic SerializableEvent

Write a script as follow, and add it to gameObject.

public class SerializableEventExample : MonoBehaviour
{
    static  SerializableEventExample(){
        //EnsureCall is required both in Editor&Runtime
        CachedCallArguementsTypeRegister.EnsureCall<string,Rect>();
        CachedCallArguementsTypeRegister.EnsureCall<Transform,Vector2,bool>();
    }

    public SerializableEvent myEvent;

    public void RunVoid(){}

    public void RunInt(int number){}

    public void RunStringRect(string name,Rect rect){}

    public void RunObjectVector2Bool(Transform target,Vector2 position,bool immediately){}
}

Editor inspector will display like :

Then, add different callbacks:

Clone this wiki locally