Unity-遇到的坑汇总

来源:互联网 发布:趣头条刷金币软件 编辑:程序博客网 时间:2024/05/21 16:57

1  

在小米Pad上崩溃:

GameObject obj =Object.Instantiate(Resources.Load(spriteNameas GameObject); 

正常:

GameObject obj = Resources.Load<GameObject>(spriteName);

Sprite sprite = obj.GetComponent<SpriteRenderer>().sprite;

GetComponent<Image>().sprite = sprite;

解决方案:

改用ugui 不用sprite  待测试 sprite在小米上的情况

(仅用Instantiate 创建有SpriteRenderer属性的Sprite会崩溃  使用小米手机正常 机器问题喽?)


2

get方法返回一个public 的bool 值 该值被改为true 不知道为何

public static GameObject instance;
    public static bool isLoading{
        get{
            return instance.GetComponent<UILoading>().building;
        }
    }

解决方案 讲bool变量设置为私有,添加public方法获取bool值。


3

ugui的Text在IOS设备掉帧严重。

解决方案:导入自定义ttf字体库 原因未知


4

ugui的image的材质如果不设置 在IOS及安卓设备上会崩溃


5

Resources.Load<GameObject>("xxx"as GameObject

这个方法。。非常非常非常的消耗性能,尤其安卓设备

如果非要使用,建议在场景加载的时候用全局方法将可能用到的资源加载到内存中


6

Xcode7编译问题. 
使用最新版本的Xcode7编译Unity3D导出来的Xcode项目.直接编译编不过.会提示有个叫做bitcode的东西.你需要在项目配置里把该bitcode设置成NO.才能编译通过.

7

ios9中
Unity3D使用HTTP协议了.就会报如下的错误. 
“App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file” 
在Info.plist中添加 NSAppTransportSecurity 类型 Dictionary ; 
在 NSAppTransportSecurity 下添加 NSAllowsArbitraryLoads 类型Boolean ,值设为 YES; 


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</plist>


8

升级到5.3.5以支持ipv6,TcpClient必须用域名访问,ipv6地址访问不成功,原因未知


9

monoDev4.9.6在Mac上无法输入,需要工程引入svn后正常,原因未知,其它解决方案未知


10

pvr压缩格式 在ios32位机器上,图片尺寸为2的幂才可以


11

new Mesh()生成的mesh必须进行销毁释放。

Mesh mesh =new Mesh();

mesh.hideFlags = HideFlags.None;

Resources.UnloadUnusedAssets ();


12

图片未放在resources文件夹下时,Android打包安装后可能导致图片丢失变黑。

解决:用spritepacker打包

0 0
原创粉丝点击