📜  将带有参数的函数添加到按钮 Unity - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:03.229000             🧑  作者: Mango

代码示例1
void Start ()
      {
          ButtonPre.onClick.AddListener(delegate{SwitchButtonHandler(0);});
          ButtonNext.onClick.AddListener(delegate{SwitchButtonHandler(1);});
      }
  
      void SwitchButtonHandler(int idx_)
      {
          //Here i want to know which button was Clicked.
          //or how to pass a param through addListener
      }