AOT generate didn't generate any support serialized type on ScriptableObject.

Issue #361 resolved
Kanipob Sdawat
created an issue
public class DBImages : SerializedScriptableObject
{

    [OdinSerialize]
    Dictionary<Enum.ItemIdentity, string> _dbItem = new Dictionary<Enum.ItemIdentity, string>();

    [OdinSerialize]
    Dictionary<Enum.MonsterElement, string> _dbMonsterElement = new Dictionary<Enum.MonsterElement, string>();

    [OdinSerialize]
    Dictionary<PGGame.Enum.SkillIdentity, string> _dbSkill = new Dictionary<PGGame.Enum.SkillIdentity, string>();

    [OdinSerialize]
    Dictionary<Tactics.TacticCtrl.TacticsMode, string> _dbTactic = new Dictionary<Tactics.TacticCtrl.TacticsMode, string>();

    public static Sprite Get(Enum.ItemIdentity e)
    {


        try
        {
            DBImages db = DBImages.Instance;
            if (db == null)
                return null;

            if (!db._dbItem.ContainsKey(e))
                return null;

            try
            {
                return Resources.Load<Sprite>(db._dbItem[e]);
            }
            catch 
            {
                Debug.LogError("DBImages unable to load sprite at:" + db._dbItem[e]);
                return null; 
            }
        }
        catch(Exception er) {
            Debug.LogError(er.Message);
            return null; 
        }

    }

    public static Sprite Get(Enum.MonsterElement e)
    {
        if (!Instance._dbMonsterElement.ContainsKey(e))
            return null;

        return Resources.Load<Sprite>(Instance._dbMonsterElement[e]);
    }

    public static Sprite Get(PGGame.Enum.SkillIdentity e)
    {
        if (!Instance._dbSkill.ContainsKey(e))
            return null;

        return Resources.Load<Sprite>(Instance._dbSkill[e]);
    }

    public static Sprite Get(Tactics.TacticCtrl.TacticsMode e)
    {
        if (!Instance._dbTactic.ContainsKey(e))
            return null;
        return Resources.Load<Sprite>(Instance._dbTactic[e]);
    }




    #region Base Part
    public static readonly string kFileName = "DB.Images.asset";
    public static readonly string kFolder = "Assets/GeneratedScripts/Resources/";
    public static readonly string kFullPath = kFolder + kFileName;


    private static DB.DBImages _instance;

    public static DB.DBImages Instance
    {
        get{

            if (_instance == null)
            {
                try
                {
                    _instance = Resources.Load<DB.DBImages>(kFileName.RemoveFilenameExtension());
                }
                catch
                {
                    throw new Exception("Unable to load DB.Image"); 
                }
            }
            if (_instance == null)
            {
                Debug.LogWarning("DB.DBImages not found. Make sure it is created");
            }

            return _instance;
        }
    }

This is my code. I tried many way and search many site to solve this but nothing work for me. In AOT Generate's message box told It'll scan the entire project. In reality , it just scan and get serialized type in Every Scene , not entire project. It didn't get serialized type on ScriptableObject.(yes! It isn't Monobehavior , It can't be in any scene) And it just leave me a empty support serialized types list.

Comments (5)

  1. Mikkel Dockweiler Sørensen
    • changed status to open

    I'll look into this issue.

    One reason for why this isn't picked up by the AOT scanner could be that the scanner might not look at Resource folders.

    Until we find a way to resolve this you should be able to manually type in the names of the types you need serialization support for in the AOT Generation preferences. I hope that helps.

  2. Mikkel Dockweiler Sørensen

    I've been unable to reproduce this issue. As soon as a DBImages instance exists the AOT scanner seems to pick it up, whether it's referenced or not.

    Is there an instanced created in your project? If not then that may be the issue.

    If the issue persists then please let us know, and we'll see if we can't get to the bottom of this.

  3. Kanipob Sdawat reporter

    Thank you for the answers.

    I solved the current issue, it can generate the support type now.

    Cause of the other asset prefab is missing and some .asset files are corrupted.

    For some error warn on console without source of error. I just remove suspected asset randomly and It works.

    By the way, It can't build iOS with IL2CPP after AOT generated. (Before It can build successfully) I'll look forward to it.

  4. Log in to comment