Search Unity

Question Two `IMoveHandler` on the same gameObject?

Discussion in 'Input System' started by Reimirno7, Jan 4, 2023.

  1. Reimirno7

    Reimirno7

    Joined:
    Nov 25, 2021
    Posts:
    51
    What happens if I have two components that implements `IMoveHandler` that are attached to the same gameObject? If that gameObject is selected and now I press up arrow key which `OnMove` gets called? Or both?

    I must be missing something here. My intention is just to override Unity's native `Button.cs`'s `OnMove` so I attached another script (call it `MyButton.cs`) that implements `IMoveHandler`. I am not sure if that is the correct way to do it.

    Based on my experiments, it seems the `OnMove` on native `Button.cs` always gets called first and the one on `MyButton.cs` gets called after that. Is this the correct behaviour / Is there relevant docs I could look up?