问题:多数情况下用UGUI的Button控件身上的OnClick()列表可以指明该按钮点击后触发的回调.现在想要调用自定义脚本里的方法,当这个脚本挂在Button所属的Canvas身上时,传入Canvas的引用虽然可以正常调用,但如果要把这个Button所属的物体作为预制体时,不知为何预制体无法保存Canvas的引用,于是考虑通过代码来给按钮添加点击回调. using UnityEngine; using System.Collections; using UnityEngine.UI; ///…
public class MyActivity extends Activity { /** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.main); final LinearLayout layout2…