当整合jar 进unity当中时,如果java 代码中需要调用findViewById(R.id.test)等类似方法,因为unity将拷贝进Plugins/Android/res目录下的文件重新生成了对应的id等。所以需要用下面方法获取:
setContentView( this.getResources().getIdentifier("camera_scan_ui", "layout", getPackageName()));
RelativeLayout mMainLayout = (RelativeLayout)findViewById( this.getResources().getIdentifier("testlayout2", "id", getPackageName()));
网友评论