美文网首页
Unity3D android findviewbyid返回 n

Unity3D android findviewbyid返回 n

作者: UnityAsk | 来源:发表于2016-08-04 21:16 被阅读105次

当整合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()));

相关文章

网友评论

      本文标题:Unity3D android findviewbyid返回 n

      本文链接:https://www.haomeiwen.com/subject/nqqhsttx.html