Ah I see. Yes this probably works. Not particular nice, but could be a workaround. I let this sink in for a while ![]()
Does anyone have guidance for this problem?
Does someone have detailed instructions to follow this? Maybe I didn’t understand clearly?
The BinaryAssetContainer is an empty script that lets you create a ScriptableObject asset in your project that will always have binary serialization, even if your project is configured to use text-based serialization.
You then will need to add child assets to your empty BinaryAssetContainer (otherwise the BinaryAssetContainer will remain empty).
Eg -
BinaryAssetContainer assetContainer = ScriptableObject.CreateInstance<BinaryAssetContainer>();
AssetDatabase.CreateAsset(assetContainer, assetPath);
AssetDatabase.AddObjectToAsset(modelIWantToSerialize, assetPath);
AssetDatabase.AddObjectToAsset(textureIWantToSerialize, assetPath);
This is just my way of hacking around the problem. Unity’s [PreferBinarySerialization] attribute is what makes it work. You could probably come up with other ways of using it for your particular application. But, this works well enough as a quick and dirty fix.
Can you give me a full example instead of a code snippet?
Please help !
That is all the code that is required for it to work - which part do you need more information about?
I need to throw it into a class or what, I mean with that code I don’t know how to implement it.
Help !
Just to inform everyone, I came up with a new trick.
That is exporting heavy prefabs to an empty project with the force binary setting and importing it again later.
You need to set the main project’s serialzie format to mixed.
oh. same question…
This is clever. Unfortunately, it does not work with Prefabs (you cannot put a prefab as a sub asset of another asset, dang).
In case anyone else stumbles on this… had the same problem, and thanks to the reddit post below I discovered that it was somehow related to the NavMesh. Clearing and rebaking fixed it.
https://www.reddit.com/r/Unity3D/comments/czqnty/force_text_not_working_on_unity_scene_files/