Search Unity

Discussion Is there a feature that works like InputAction.CallbackContext but is decoupled from anything?

Discussion in 'Scripting' started by halfblue3, Jan 1, 2024.

  1. halfblue3

    halfblue3

    Joined:
    Mar 5, 2019
    Posts:
    11
    I'm currently looking for a way to implement callbacks which also have a wiggle room to be able to call multiple callbacks and something that appears in the Inspector, and I remember PlayerInput has an amazing feature if you set it to "Invoke Unity Events" behavior and saw that this amazing feature is called CallbackContext. When I looked around, it seems like it's tied to InputAction and was kinda disappointed.
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,923
    It's just a struct nested within
    InputAction
    , it doesn't mean it's 'coupled'. It's just a parameter you need in the signature of methods that you subscribe to the various InputAction callbacks.
     
  3. halfblue3

    halfblue3

    Joined:
    Mar 5, 2019
    Posts:
    11
    Sure, it might not be really coupled with InputAction, but it still means it's owned by InputAction. So I don't think it would be smart to just use it on it's own just because you can. And well, I don't really need/want to interact with InputAction to trigger the callbacks. Well, it is surely involved in the process, but I have a bit more processing before I want to call the callbacks.
     
  4. But why?
     
  5. halfblue3

    halfblue3

    Joined:
    Mar 5, 2019
    Posts:
    11
    I think I already found what I need. It seems like UnityEvent would work just like CallbackContext. Will test it out tomorrow
     
  6. halfblue3

    halfblue3

    Joined:
    Mar 5, 2019
    Posts:
    11
    Emm, because it wasn't it's intended purpose? And it has some caveats that I don't want/need to deal with. So I'd rather find a tool/feature that is much more suited to what I want to do. And I haven't exhausted my options yet, so I don't want to use it yet.