现在我正在使用 UIEventListener 添加一个点击器。当我将它写入一个文件时,它可以正常工作。像这样:
UIEventListener.Get(popButton).onClick = showPop;
但是当我将它写入两个单独的文件时,它给了我 error.first 文件:
public class Adapter{
var grid:GameObject;
function addItems(data:List.<PrintItem>, prefab:GameObject, func:Function){
for(var i:int=0;i<data.Count;i++){
var gameObject:GameObject = NGUITools.AddChild(grid, prefab);
UIEventListener.Get(gameObject).onClick = func;
}
}
}
第二个文件:
//I use the funtion like this
adapter.addItems(list, GO[0], hidePop);
//the hidePop is like this
var hidePop:Function = function(){
switchPopMenu(false);
};
当我运行统一时给我错误
InvalidCastException: Cannot cast from source type to destination type.
Adapter.addItems (System.Collections.Generic.List`1 data,
UnityEngine.GameObject prefab, ICallable func) (at
Assets/Scripts/yhj/Tools/Adapter.js:12)