Search Unity

Bug Events callback is not consistent with C#, and that's weird

Discussion in 'Input System' started by FVS, Mar 18, 2021.

  1. FVS

    FVS

    Joined:
    Aug 10, 2015
    Posts:
    58
    Consider the script below. When the action got triggered, only "A" and "C" got printed to the console. That's definitely bad because B is in no way aware of that. And I don't know how they can do that (not an expert with the underlying code of the engine), but I tested a similar case with an event I defined, only "A" and "B" got logged (and I think it's much better that way).

    Code (CSharp):
    1.  public class TestScript_2 : MonoBehaviour
    2.     {
    3.         [SerializeField]
    4.         private InputActionReference iaa;
    5.  
    6.         protected void Awake()
    7.         {  
    8.             ///
    9.             iaa.action.Enable();
    10.  
    11.             ///
    12.             iaa.action.performed += MethodA;
    13.             iaa.action.performed += MethodB;
    14.         }
    15.  
    16.         private void MethodA(InputAction.CallbackContext cc)
    17.         {
    18.             Debug.Log("A");
    19.  
    20.             iaa.action.performed -= MethodA;
    21.             iaa.action.performed += MethodC;
    22.         }
    23.  
    24.         private void MethodB(InputAction.CallbackContext cc)
    25.         {
    26.             Debug.Log("B");
    27.         }
    28.  
    29.         private void MethodC(InputAction.CallbackContext cc)
    30.         {
    31.             Debug.Log("C");
    32.         }
    33.     }
     
  2. Have you submitted a bug?
     
  3. FVS

    FVS

    Joined:
    Aug 10, 2015
    Posts:
    58
    I did, asked first to make sure it was not because of something I was missing. Here's the link they emailed me: https://fogbugz.unity3d.com/...

    I thought it would have some kind of page so others can vote on the issue
     
    Last edited: Mar 18, 2021
  4. You shouldn't share fogbugz links online. It gives access all of your bug reports, both past and future. Sooner or later you will share some personal or otherwise protected information you would like to not to share with the internet.

    After you submit a bug report, someone from Unity will take a look, if they can reproduce your problem (probably will, because I could) they will create the issue tracker entry and that can be shared (it doesn't contain any of your personal information or your emails in any way) with the voting capability and all.
     
    FVS likes this.
  5. FVS

    FVS

    Joined:
    Aug 10, 2015
    Posts:
    58
    They said the behaviour is expected. But you know it is absurd, right?
    Here's their reply:
    Hi,

    Thanks for contacting us!

    I have contacted developers directly about this issue and this behavior is expected. First A and C happen, then A is removed and then only B and C happens.

    If you have any further questions, feel free to contact us.
     
  6. I personally would never, ever use this insane pattern, so whatever they decide is intentional, it's fine by me. There is nothing "absurd" about it.
     
  7. FVS

    FVS

    Joined:
    Aug 10, 2015
    Posts:
    58
    well, now they say it's not expected behavior.
    Hi,

    Thanks for your response.

    Upon further discussion in our team, it seems like this is not expected behavior. It will be possible to follow the progress on a chosen resolution in our public Issue Tracker once the report has been processed:
    [link]
    We highly appreciate your contribution. If you have further questions, please feel free to contact us.
     
  8. FVS

    FVS

    Joined:
    Aug 10, 2015
    Posts:
    58