MerlinVR / UdonSharp

An experimental compiler for compiling C# to Udon assembly
MIT License
678 stars 89 forks source link

Calling SendCustomEvent from AnimationEvent #58

Closed ikuko closed 4 years ago

ikuko commented 4 years ago

Describe the bug in detail: Call SendCustomEvent from AnimationEvent using Animator etc. Some situations cause problems when running in the editor.

Provide steps/code to reproduce the bug:

  1. Prepare the following USharp code and set it in UdonBehaviour.

    public class Test : UdonSharpBehaviour
    {
    int num;
    
    private void Start()
    {
        num = 123;
    }
    
    public void Method()
    {
        Debug.Log($"num={num}");
    }
    }
  2. Execute SendCustomEvent with "Method" argument in AnimationEvent.

  3. When executed in the editor, the following is output to the console.

    num=123
    num=0

    The first output is the result of being run via Udon Behavior. The second output is the result of a reflection run via UdonSharpBehaviour.

Expected behavior: It should only be called once, but it has been called twice. The second call should not be made.

Additional Information: Provide any additional information here.