Unity3D引擎崩溃、异常、警告、BUG的解决方法
2015-11-04 14:45阅读:

1.Unity3D经常莫名奇妙崩溃。
一般是由于空异常造成的,多多检查自己的引用是否空指针。
2.编码切换警告提示。
警告提示:Some are Mac OS X (UNIX) and some are
Windows.
This might lead to incorrect line numbers in stacktraces
andcompiler
errors. Many text editors can fix this using Convert LineEndings
menu
commands.
编码格式问题,VS的话直接高级保存方案里面修改,一般我选的是UNICODE(UTF8代签名)MACINTOSH(CR),WINDOW下的可以选WINDOWS的格式,两边都要用的话,推荐选CR。
3.中文界面解决问题。
monodevelop中文显示解决方法:
中文Mac系统下MonoDevelop乱码解决:
4.安装空项目报错
不知道怎么地,在IOS试过一次空项目也在错误提示。大概是说什么“找不到需要的方法”。
重装一下就好了,估计是UNITY文件损坏或者安装不完全出错了。
错误提示:MissingMethodException: Cannot find the
requestedmethod.
估计是破解Unity3D造成的,该破解文件可能是不支持WIN7下的。
解决方法:换正版或换个破解文件。
5.平台编译错误或库引用缺失
错误提示:error CS1061: Type `System.IO.FileInfo' does not
containa definition
for `Delete' and no extension method `Delete' of
type`System.IO.FileInfo'
could be found (are you missing a usingdirective or an
assembly
reference?)
出了这个错误一般有两个原因了。
1.没有引用相关的库。
2.选错编译平台。(BuildSetting里面的Platform)
错误提示:Could not
startcompilationWin32Exception:ApplicationName=“XXXX\mono.exe”,……
解决方式:重装UNITY3D。
6.内存资源加载错误问题
错误提示:Trying to reload asset from disk that is not stored
ondisk
个人是在加载多个ASSETBUNDLE时,用了释放镜像之后,发生了下面的BUG。
这个警告它并没有对游戏流程有任何影响,不过一直跳出来很烦人。我们项目中是因为用Dictionary删除的时候没有删除完整导致的。
个人认为比较大可能是下面的原因:
还没释放完镜像再次加载就出BUG了。将所有ASSETBUNDLE加载完后再同一释放,这样就没问题了。
Unity will only allow you to have a single instance of
aparticular
AssetBundle loaded at one time in your application.
Whatthis means is that you can't retrieve an AssetBundle from
a WWWobject
if the same one has been loaded previously and has not
beenunloaded.
In practical terms it means that when you try to access
apreviously loaded
AssetBundle like this:
(BY:http://docs.unity3d.com/Documentation/Manual/keepingtrackofloadedassetbundles.html)
国外论坛的讨论:
http://forum.unity3d.com/threads/49298-Trying-to-reload-asset-from-disk-that-is-not-stored-on-disk
貌似老外也没完全确切搞定这个。
错误提示:Deletingpersistent object without writing it
first
不论如何你都不应该直接修改一个从assetbundle加载进来的最初数据,一般都要先实例化出来再对其修改。但是引用的东西(例如mesh),这些也不能修改它。若要修改的话,则先复制一份出来。
复制一份模型出来重新复制,以免直接修改被引用的镜像模型。如下:
Mesh temp = Mesh.Instantiate(smr.sharedMesh) as
Mesh;
myMesh.sharedMesh = temp;