usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingUnityEngine.UI;publicclassTest:MonoBehaviour{publicButton[] btn;privatevoidStart(){for(int i =0; i < btn.Length; i++){int a = i;btn[i].onClick.AddListener(delegate{BtnOnClick(a);});}}publicvoidBtnOnClick(intvalue){Debug.Log("打印信息"+value);}}
通常,C创建一个对象,都是调用构造函数对它初始化:
class AB {int a;int b;
public:AB(int ia, int ib) {aia; bib;}void display() {printf("a%d, b%d\n", a, b);}void other();
};如果实现过程需要施加更多的控制,比如…