如何解决错误:A script behaviour has a different serialization layout when loading
来源:互联网 发布:淘宝网邮票真假 编辑:程序博客网 时间:2024/06/05 16:54
在实际开发中碰到一个问题,加载一个Prefab,Unity会报以下错误:
A script behaviour has a different serialization layout when loading. (Read 24 bytes but expected 40 bytes), Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
这是代码:
using UnityEngine;public class ObjectPreview : MonoBehaviour { #if UNITY_EDITORpublic GameObject obj;void Start () {// code ...} #endif}也就是说,,ObjectPreview在编辑器模式下和非编辑器模式下, 序列化出来的内容是不同的
那么, 由于美术(或者其它团队成员)做的Prefab是在编辑器环境下产生的, 所以是带有obj的序列化数据
但是在运行时, 由于这个UNITY_EDITOR宏,导致运行时与编辑器 序列化内容不同!
正确的做法是去掉 #if UNITY_EDITOR,或者把#if UNITY_EDITOR包住整个类!
0 0
- 【Unity3d】如何解决错误:A script behaviour has a different serialization layout when loading
- 如何解决错误:A script behaviour has a different serialization layout when loading
- 如何解决错误:A script behaviour has a different serialization layout when loading
- When and Why the Superclass Method Has a Different Access Level
- A Java Exception has occurred错误解决
- When is a CDATA section necessary within a script tag?
- 解决“A problem has been encountered while loading the setup components. Canceling setup.”的问题
- 解决“A problem has been encountered while loading the setup components. Canceling setup.”的问题
- 解决“A problem has been encountered while loading the setup components. Canceling setup.”的问题
- qt QLayout: Attempting to add QLayout "" to MainWindow "", which already has a layout. 错误
- [顶]Different ways of loading a file as an InputStream
- Getting a warning containing "too many libraries when loading *.so"
- dwr:A request has been denied as a potential CSRF attack.错误的解决
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 用jetty跑maven项目(详细版,适合小白)
- 【Clojure】在loop-recur中实现多重循环
- hihocoder#1051 : 补提交卡....惊了..这题竟然被我发现测试数据的漏洞....
- 对于block的理解及用法的注意
- jquery validate对于多个同样名称的name进行验证
- 如何解决错误:A script behaviour has a different serialization layout when loading
- [leetcode] 373. Find K Pairs with Smallest Sums 解题报告
- Two Sum III – Data structure design
- 设置RecyclerView项目之间的间距
- Ubuntu 16.04中如何修改mysql的编码为utf-8
- RecyclerView的item监听
- Android值数据读写在sd卡需要注意的事项
- java自学循环与选择性语句及表达式语句运算
- java设计模式:(策略模式)