Skip to content

Support for non value types. #6

@ghost

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions