ShapesImportState Resource

Avatar
  • updated

Hello! We love Shapes and it's great! Ran into a bug that was a little tricky to track down.


We've got a workaround for this so this is not a priority for us, feel free to ignore it, just posting here in case you get reports from other folks or someone else has a similar problem.

  • Shapes has a "Shapes Import State" ScriptableObject Asset in it's Shapes/Resources folder
  • When this asset is included in a build, we get an error: 

The referenced script (Unknown) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object '<null>') is missing!
A scripted object (script unknown or not yet loaded) has a different serialization layout when loading. (Read 52 bytes but expected 56 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
UnityEngine.ResourcesAPI:LoadAll(String, Type) (at C:\buildslave\unity\build\Runtime\Export\Resources\Resources.bindings.cs:72)
UnityEngine.Resources:LoadAll(String, Type) (at C:\buildslave\unity\build\Runtime\Export\Resources\Resources.bindings.cs:143)
UnityEngine.Resources:LoadAll(String) (at C:\buildslave\unity\build\Runtime\Export\Resources\Resources.bindings.cs:155)

  • This happens the first time we try to call UnityEngine.Resources.LoadAll<Texture>(""); for any type of resource, doesn't have to be Texture.

I'm not sure why exactly this is causing a problem, the #defines look OK to me, but removing the ShapesImportState Asset fixes the error.

Using Resources.LoadAll is not a good idea and we're moving away from that, but it's being used in a (different) third-party asset at the moment.

Thanks!

Reporting a bug? please specify Unity version:
2021.3.4f1
Reporting a bug? please specify Shapes version:
4.1.3
Reporting a bug? please specify Render Pipeline:
URP
Avatar
joeld-gt

Update: Realized that this is happening because ShapesImportState is in an Editor/ Folder so it doesn't get compiled in a standalone build, but the ShapesImportState asset is not in an Editor folder so it does get included, but the class to unserialize it is not included. 

Avatar
jean-paul

Thanks for the heads-up, I was able to work around this by never calling Resources.LoadAll<SomeType>("") with an empty string, but now I've just moved the ShapesImportState asset to the Editor/Resources folder to solve this...