Skip to content

TargetParameterCountException on instance event calling static methods #7

Description

@marc-antoine-girard

Description:

Unity throws TargetParameterCountException

  • when an instanced ExtEvent calls a static method with one parameter (int in my case).
  • It does not throw when calling a method without parameter.
  • It does not throw when the ExtEvent is set to static and is calling a static method with a parameter.

Expected:

Calling a static method with one parameter using an instance event should behave the same way as calling a static method with no parameter using an instance event.

How to reproduce:

Given the code below:

public class Test : MonoBehaviour
{
    public ExtEvent voidEvent;

    private void OnEnable()
    {
        voidEvent.Invoke();
    }

    public static void StaticCallNoArg()
    {
        Debug.Log("StaticCallNoArg");
    }
    public static void StaticCallOneArg(int a)
    {
        Debug.Log($"StaticCallOneArg {a}");
    }
    public void InstanceCallNoArg()
    {
        Debug.Log("InstanceCallNoArg");
    }

    public void InstanceCallOneArg(int a)
    {
        Debug.Log($"InstanceCallOneArg {a}");
    }
}

image
(red one throws)

Output:
image

Additional information:

  • Unity 2021.3.9
  • ExtEvents 1.7.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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