Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it's possible to use opensource version of Odin serializer in IL2CPP? #49

Open
Syjgin opened this issue Nov 20, 2021 · 2 comments
Open

Comments

@Syjgin
Copy link

Syjgin commented Nov 20, 2021

Hi. I was trying to use opensource version of Odin serializer (downloaded unitypackage from the site after registration), but it looks like I can not use it without Unity editor tools. Serialization is not working in IL2CPP build with the error message:
No AOT serializer was pre-generated for the type 'Components.GameScene'. Please use Odin's AOT generation feature to generate an AOT dll before building, and ensure that 'Components.GameScene' is in the list of supported types after a scan. If it is not, please report an issue and add it to the list manually.
Components.GameScene is declared as follows:
[Serializable] public enum GameScene { Menu = 0, Flying = 1, Platform = 2 }
I can not found that list in the editor: I have only "refresh assembly import settings" in the "Tools-> Odin Serializer" menu. I have to install Odin inspector to be able to edit that supported types list?
I also created prebuild script to generate .dll:
`#if UNITY_EDITOR
using OdinSerializer.Editor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;

namespace Editor
{
public class OdinFormatterPreprocessor : IPreprocessBuildWithReport
{
public int callbackOrder { get; }
public void OnPreprocessBuild(BuildReport report)
{
if (AOTSupportUtilities.ScanProjectForSerializedTypes(out var supported))
{
AOTSupportUtilities.GenerateDLL(Application.dataPath + "/Plugins/", "odinAssembly", supported);
}
}
}
}
#endif`

But nothing changed. I have to install Odin inspector in order to be able to use serializer with AOT, or there are some other setup is required? Can't find the appropriate documentation

@pshtif
Copy link

pshtif commented Nov 21, 2021

Yes it is possible but the Odin Serializer doesn't have the editor tools to do the scanning/type management for you that is only part of the Odin Inspector but it is still perfectly doable to implement your own Scanning tools using Odin Serializer methods.

In your case you can also manually add the GameScene type to the supported list explicitly for it to be included in the DLL.

But as I said it can be implemented I implemented custom editor tools for scanning and explicit type definition here: https://github.com/pshtif/Dash

@Syjgin
Copy link
Author

Syjgin commented Nov 23, 2021

Ok, I will check this later, but of now Binary serializer is enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants