unity中自适应

6T5@}IRZ(_D~VT~T70ON1DR.png

在fariygui 中可以自适应 在unity中就出现了图中的现象
 
代码是这样的 
 GRoot.inst.SetContentScaleFactor(750, 1334, UIContentScaler.ScreenMatchMode.MatchWidthOrHeight);
        UIPackage.AddPackage("UI/MainUI");
        GComponent gcom = UIPackage.CreateObject("MainUI", "main").asCom;

         gcom.SetSize(GRoot.inst.width, GRoot.inst.height);

        gcom.x = (GRoot.inst.width - gcom.width)/2;
 
 
 
这个设置导出apk 后 竖屏不对 横屏对
已邀请:

xiatianjin

赞同来自:

解决了 加了这个 gcom.y = (GRoot.inst.height - gcom.height)/2;  就可以了  

tiance7

赞同来自:

fgui有相对布局 设置下就好了不用写代码

要回复问题请先登录注册