Search Unity

Nested events - How to invoke mouse event click within mouse event click?

Discussion in 'Input System' started by FellowPlayer123, Apr 27, 2021.

  1. FellowPlayer123

    FellowPlayer123

    Joined:
    Dec 23, 2016
    Posts:
    114
    Hi,

    On mouse button click, I perform "Attack" method.
    Within this method, I would like to check if the mouse button was pressed once again (user confirmation).
    How is it achievable in this new Input System?

    Code (CSharp):
    1.  
    2.  
    3. void OnAttack(InputAction.CallbackContext context)
    4. {
    5.     if (context.performed)
    6.     {
    7.         Attack();
    8.      
    9.     }
    10. }
    11.  
    12. void Attack()
    13. {
    14.     if(type1)
    15.     {
    16.         PrepareType1();
    17.         if(mouseclick) // confirm type1
    18.         {
    19.             ExecuteType1();
    20.         }
    21.     }
    22.  
    23. }
    24.  
     
  2. FellowPlayer123

    FellowPlayer123

    Joined:
    Dec 23, 2016
    Posts:
    114
    No response? This should be the most basic stuff.
     
  3. Code (CSharp):
    1.     void OnAttack(InputAction.CallbackContext context)
    2.     {
    3.         if (context.performed)
    4.         {
    5.             Attack(true);
    6.         }
    7.     }
    8.     void Attack(bool onAttackContext = false)
    9.     {
    10.         if(type1)
    11.         {
    12.             PrepareType1();
    13.             if(onAttackContext) // confirm type1
    14.             {
    15.                 ExecuteType1();
    16.             }
    17.         }
    18.     }
    19.  
    Did you think something like this? Or something else? I really don't understand what are you confirming... What do you mean when you use the term "user confirmation"?