Unity 按钮添加OnClick事件操作

  using UnityEngine;

  using System.Collections;

  using System.Collections.Generic;

  using UnityEngine.Events;

  using UnityEngine.UI;

  public class ButtonOnClickTest: MonoBehaviour {

  // Use this for initialization

  void Start () {

  List btnsName = new List();

  btnsName.Add("BtnPlay");

  btnsName.Add("BtnShop");

  btnsName.Add("BtnLeaderboards");

  foreach(string btnName in btnsName)

  {

  GameObject btnObj = GameObject.Find(btnName);

  Button btn = btnObj.GetComponent