SerializableCallback
SerializableCallback copied to clipboard
Support for non value types.
UnityEvent has support for common serialized types not inherited from UnityEngine.Object. By debugging the code, it seems that SerializableCallback has a validation method for parameters that checks if they are a value type and inherits from UnityEngine.Object, and returns invalid if they not. So for feature parity with UnityEvent, SerializableCallback should support these custom types.
Example: Add this Component to a GameObject, and try to select the dynamic method TestMethod from both the UnityEvent and the SerializableEvent. Only the UnityEvent will provide the option.
using UnityEngine;
using UnityEngine.Events;
public class TestCallbackReceiver : MonoBehaviour {
[System.Serializable]
public class TestClass
{
public int a;
public int b;
}
[System.Serializable] public class TestUnityEvent: UnityEvent<TestClass, bool, bool> {}
[System.Serializable] public class TestSerializableCallback: SerializableEvent<TestClass, bool, bool> {}
public TestUnityEvent testEvent;
public TestSerializableCallback testSerializableCallback;
public void TestMethod(TestClass a, bool b, bool c)
{
Debug.Log("only detected by UnityEvent");
}
}