Search Unity

Disable InputAction in the canceled callback will case cycle call. stack overflow

Discussion in 'Input System' started by wang37921, Aug 7, 2020.

  1. wang37921

    wang37921

    Joined:
    Aug 1, 2014
    Posts:
    102
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Threading.Tasks;
    4. using UnityEngine;
    5. using UnityEngine.InputSystem;
    6.  
    7. public class NewBehaviourScript : MonoBehaviour
    8. {
    9.     InputAction input;
    10.  
    11.     void Start()
    12.     {
    13.         input = new InputAction("test", InputActionType.Button, "<Mouse>/leftButton");
    14.         input.canceled += e=>{
    15.             input.Disable();
    16.         };
    17.         input.Enable();
    18.     }
    19. }
    20.  
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Works fine in current develop branch. I assume this was fixed by the recent changes to protect from action callbacks causing problems in internal action state.

    1.1 with the fixes is scheduled to go out next week.
     
    wang37921 likes this.