Error with Win64 build: A script behaviour (probably FMODUnity.EditorParamRef?) has a different serialization layout when loading

Getting this error with a Win64 development build of our game on 2.00.01. There aren’t any errors when we play in the Unity Editor, 2018.1.5f1. Any suggestions?

A script behaviour (probably FMODUnity.EditorParamRef?) has a different serialization layout when loading. (Read 32 bytes but expected 80 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

My uneducated guess is the PARAMETER_ID struct as part of the EditorParamRef class is causing the problem. Previous versions of FMOD integrations don’t have that field.

My guess would be marking the PARAMETER_ID struct as serializable:

[global::System.Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct PARAMETER_ID
{
    public uint data1;  /* The first half of the ID. */
    public uint data2;  /* The second half of the ID. */
}

But I don’t know sadly. However, I’d probably stay away from 2.00.00 until it’s out of early access if this is for a serious project. Otherwise, you may be waiting for an official patch.

Does this fix the issue?

Unfortunately, no, the issue still persists after marking PARAMETER_ID as serializable.

Are you able to reproduce this in an empty project?
I have not been able to reproduce it to be able to test it further.
Do the logs provide any more information on the error?

This is specific to our project for some reason. We are using the Adventure Creator Unity plugin, so it could be something incompatible with that. But we weren’t getting these errors before FMOD 2.0 and we’ve stayed on the same versions of both AC and Unity. I can send the whole log over if that would help.

The errors always appear after loading a specific scene and then just loop over and over in the log after this:

The referenced script (Unknown) on this Behaviour is missing!
UnityEngine.Resources:LoadAll(String, Type)
AC.LevelStorage:UnloadTransformData(List`1, SubScene) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:382)
AC.LevelStorage:SendDataToScene(SingleLevelData, Boolean, SubScene) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:119)
AC.LevelStorage:ReturnCurrentLevelData(Boolean) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:77)
AC.SceneSettings:OnStart() (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Game engine\SceneSettings.cs:129)
AC.MultiSceneChecker:Start() (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Game engine\MultiSceneChecker.cs:72)

[C:\buildslave\unity\build\Runtime/Mono/MonoBehaviour.cpp line 1576] 
(Filename: D:/Repos/SpiritOfMidnight/Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs Line: 382)

The referenced script on this Behaviour (Game Object '<null>') is missing!
UnityEngine.Resources:LoadAll(String, Type)
AC.LevelStorage:UnloadTransformData(List`1, SubScene) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:382)
AC.LevelStorage:SendDataToScene(SingleLevelData, Boolean, SubScene) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:119)
AC.LevelStorage:ReturnCurrentLevelData(Boolean) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:77)
AC.SceneSettings:OnStart() (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Game engine\SceneSettings.cs:129)
AC.MultiSceneChecker:Start() (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Game engine\MultiSceneChecker.cs:72)

[C:\buildslave\unity\build\Runtime/Mono/MonoBehaviour.cpp line 1789] 
(Filename: D:/Repos/SpiritOfMidnight/Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs Line: 382)

A script behaviour (script unknown or not yet loaded) has a different serialization layout when loading. (Read 48 bytes but expected 896 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
UnityEngine.Resources:LoadAll(String, Type)
AC.LevelStorage:UnloadTransformData(List`1, SubScene) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:382)
AC.LevelStorage:SendDataToScene(SingleLevelData, Boolean, SubScene) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:119)
AC.LevelStorage:ReturnCurrentLevelData(Boolean) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:77)
AC.SceneSettings:OnStart() (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Game engine\SceneSettings.cs:129)
AC.MultiSceneChecker:Start() (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Game engine\MultiSceneChecker.cs:72)

[C:\buildslave\unity\build\Runtime/Serialize/SerializedFile.cpp line 1967] 
(Filename: D:/Repos/SpiritOfMidnight/Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs Line: 382)

The referenced script (FMODUnity.EditorBankRef) on this Behaviour is missing!
UnityEngine.Resources:LoadAll(String, Type)
AC.LevelStorage:UnloadTransformData(List`1, SubScene) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:382)
AC.LevelStorage:SendDataToScene(SingleLevelData, Boolean, SubScene) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:119)
AC.LevelStorage:ReturnCurrentLevelData(Boolean) (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Save system\LevelStorage.cs:77)
AC.SceneSettings:OnStart() (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Game engine\SceneSettings.cs:129)
AC.MultiSceneChecker:Start() (at D:\Repos\SpiritOfMidnight\Assets\AdventureCreator\Scripts\Game engine\MultiSceneChecker.cs:72)

If you would like to send the entire log file to support@fmod.com, I can take a look.

Although it looks like UnityEngine.Resources:LoadAll is trying to load the FMOD Editor files, they don’t get included in built games (like all other Editor files).

Sent the log so you can check it out in full.

If it does end up being the UnityEngine.Resources:LoadAll call, is that an issue that only the Adventure Creator folks can fix? Or is this a Unity issue? I was under the assumption that Unity handled files in Editor folders gracefully.

Unity does strip out all Editor files when building a game, this is also why you are getting:

The referenced script (FMODUnity.EditorBankRef) on this Behaviour is missing!

I don’t know how the Adventure Creator is populating a list of resources to load but it seems to be including the EditorBankRef, which is used for displaying bank information in the Editor inspector (Eg. StudioBankLoader script).

You will need to contact the creators of the Adventure Creator plugin.

Gotcha, will do - thanks a bunch for your help!

Just in case anyone happens to drop in here with a similar issue, this is a link to the continuation on Adventure Creator’s forums: https://www.adventurecreator.org/forum/discussion/8900/ac-trying-to-load-editor-specific-fmod-classes-resulting-in-build-errors

1 Like

Haven’t checked if this has been fixed in a future update, but this is caused by FMODStudioCache.asset lying in a Resources folder and some other code running a Resources.LoadAll() without any path specification. Unity tries deserializing an editor-only asset and fails, displaying the error message.

The simple solution is to move the FMODStudioCache.asset to another folder, as it shouldn’t be in Resources to begin with. I changed the path EventManager.CacheAssetFullName to another folder and made sure it existed in my project, then deleted the old cache and let it regenerate.

It does, but the FMODStudioCache.asset isn’t an editor file. Is there a particular reason it’s in a Resources folder? Just want to avoid having shot myself in the foot if a planned feature comes around and breaks our fmod because I moved it. ^^

I’ve just hit this problem as well. This is an incompatibility with the Unity API as it supports loading resoureces by type like so:

var configs = Resources.LoadAll("", typeof(MapLoadConfig));

AFAIK all files in Resources folder are included in the build. If you want to access the assets in the editor you should be using AssetDatabase API, not Resources.

Seems I was mistaken. Nonetheless I’d like a better solution that “avoid loading resources by type” if possible.

We have a task to move the files out of the resources folder to avoid this issue. It is currently scheduled for the release at the start of December.

1 Like