美文网首页
(转)Unity3D bug积累

(转)Unity3D bug积累

作者: playboy | 来源:发表于2021-07-23 09:29 被阅读0次

    1:mp3没有声音

    如图:导入到场景中的mp3格式的音乐在预览界面点击播放,听不到声音。但是用外部播放器打开对应文件夹下的该文件却有声音的。

    把文件删除、重新导入,依旧没有声音。

    最后重启Unity3D,尼玛,可以了。。。这个BUG,3年前就存在了。。

    2:图片导入后Could not create texture from XXXX;File could not be read.

    无论是直接复制粘贴到unity3d文件夹内还是用import都报错如下。图片是白色的,不显示内容。

    解决方法:用photoshop打开,重新保存一道。可能是编码的问题吧~~~

    2:Build Problem - asset is marked as don’t save

    20140512(汶川六年)

    今天做电影学院3D互动项目,切换为成android平台后,build and run的时候报了一些列错。如下图:

    Error 1:

    An asset is marked as dont save, but is included in the build:

    UnityEditor.HostView:OnGUI()

    Error 2:

    Building - Failed to write file: sharedassets0.assets UnityEditor.HostView:OnGUI()

    Error 3:

    Error building Player: Couldn’t build player because of unsupported data on target platform.

    这是论坛上对该问题的讨论:http://answers.unity3d.com/answers/706282/view.html

    我关闭unity后,重新打开。问题消失

    3:Profiler LogStringToConsole

    Necromancy项目,主角死亡后,复活后帧率极度下降,打开profiler

    发现FriendAnimationControl.cs脚本中的debug占用了几乎全部的内存消耗。

    问题是FriendAnimationControl.cs上的脚本已经完全注释了Debug.Log以及Printf了。

    最终终于找到原因:http://forum.unity3d.com/threads/profiler-showing-logstringtoconsole-what-is-that.237589/#post-1577507

    如上图,在Console面板点击Open Editor Log

    在详细的Editor Log中发现了很多句如下信息:

    !(Log信息)[/img/LogClear.png]

    这些信息,被当作垃圾debug信息,没有显示在Console的面板中,只能通过Log日志看到。

    于是追本溯源,在FriendAnimationControl.cs脚本中发现在主角死亡的时候设置了animator.runtimeAnimatorController = null;

    导致主角复活后,友军继续执行animator.SetBool之类的操作,报错Animator has not been initialized。可惜的是该报错被当作垃圾信息了……

    4: Shader wants normals, but the mesh XXX doesn’t have them的警告

    找到名为XXX的mesh,发现其用的shader 是diffuse,根本不需要法线贴图。

    再仔细看看,这个XXX mesh是用代码生成的。于是最后调用了RecalculateNormals()方法,顺利解决。(_trailMesh.RecalculateNormals());

    5:Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption

    出现情况描述:Resource.Load了一个Prefab,并as强制转换为GameObject类型bb。然后设置bb的父物体为场景中已知的物体。报错如上。

    解决方法:还必须Instantiate一下bb,并存到cc中,然后就可以随便操纵cc了,不会发生上述报错:

    GameObject bb=Resources.Load(XXX) as GameObject;

    GameObject cc=Instantiate(bb);

    转自:http://bbbbbbion.github.io/2015/10/03/Unity3D%20bug%E7%A7%AF%E7%B4%AF/

    相关文章

      网友评论

          本文标题:(转)Unity3D bug积累

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