Error building player because script class layout is incompatible between the editor and the player

解决办法

  • 【临时办法】根据提示,删除/注释掉对应class中的序列化标签[Serializable]/[XmlRoot]/[XmlElement]等各种序列化标签属性。打完包后再恢复这些标签
  • 【躺平办法】等它自己好😂

Unity3D 版本

  • 2022.1.23f1c1

出现时机

  • 当使用了BuildPipeline:BuildAssetBundles打包时,出现

Error info

  • Type '[Assembly-CSharp]BaseToolsForUnity.AssetInfo' has an extra field 'assetName' of type 'System.String' in the player and thus can't be serialized (expected 'abName' of type 'System.String')

    UnityEditor.BuildPipeline:BuildAssetBundles (string,UnityEditor.BuildAssetBundleOptions,UnityEditor.BuildTarget)

    AssetBundleBrowser.AssetBundleDataSource.AssetDatabaseABDataSource:BuildAssetBundles (AssetBundleBrowser.AssetBundleDataSource.ABBuildInfo) (at Assets/Editor/AssetBundles-Browser-master/AssetBundles-Browser-master/Editor/AssetBundleDataSource/AssetDatabaseABDataSource.cs:87)

    AssetBundleBrowser.AssetBundleBuildTab:ExecuteBuild () (at Assets/Editor/AssetBundles-Browser-master/AssetBundles-Browser-master/Editor/AssetBundleBuildTab.cs:359)
    UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

传送门

Unity forum 中有个相关帖子

posted @ 2022-12-22 17:49  清风0307  阅读(641)  评论(0编辑  收藏  举报