SerializableCallback icon indicating copy to clipboard operation
SerializableCallback copied to clipboard

Support for non value types.

Open ghost opened this issue 7 years ago • 1 comments

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");
    }
}

ghost avatar Dec 01 '18 18:12 ghost

I added this feature here. You can use my fork.

mnicolas94 avatar Sep 12 '23 18:09 mnicolas94