Skip to content

Dictionary serialization with <enum, MonoBehaviour> leads to an error #108

@TaggedDev

Description

@TaggedDev

Unity Version: 2022.3.4f1
Alchemy Version: 2.0.1
Serialization Version 3.1.2

I've tried to create a serializable dictionary with <int, int> and <string, int> and it work's perfectly fine. But trying to make a dictionary containing enum or monobehaviour in Key or Value like:

[AlchemySerializeField, NonSerialized] private Dictionary<UnitTeam, GameObject> dictionary = new();
// or
[AlchemySerializeField, NonSerialized] private Dictionary<int, BasicUnit> dictionary = new();
// or
[AlchemySerializeField, NonSerialized] private Dictionary<UnitTeam, BasicUnit> dictionary = new();
public enum UnitTeam
{
	Ally, 
	Enemy
}

public class BasicUnit : MonoBehaviour
{
}

leads to an error:

Script updater for Library\Bee\artifacts\1900b0aEDbg.dag\Assembly-CSharp.dll failed to produce updates.txt file (response file: Library/Bee/artifacts/1900b0aEDbg.dag/Assembly-CSharp.rsp, MovedFromCache: Z:/Code/UnityProjects/Artillery/ArtilleryGame/Library/Bee/artifacts/1900b0aEDbg.dag/Assembly-CSharp.dll.mvfrm
Alchemy.SourceGenerator\Alchemy.SourceGenerator.AlchemySerializeGenerator\Artillery.Entities.Units.Configuration.UnitConfiguration.AlchemySerializeGenerator.g.cs(27,143): error CS0234: The type or namespace name 'Entities' does not exist in the namespace 'Artillery.Artillery' (are you missing an assembly reference?)
Alchemy.SourceGenerator\Alchemy.SourceGenerator.AlchemySerializeGenerator\Artillery.Entities.Units.Configuration.UnitConfiguration.AlchemySerializeGenerator.g.cs(27,27): error CS0029: Cannot implicitly convert type 'System.Collections.Generic.Dictionary<Artillery.Artillery.Entities.UnitTeam, UnityEngine.GameObject>' to 'System.Collections.Generic.Dictionary<Artillery.Entities.UnitTeam, UnityEngine.GameObject>'

I see the error says about the namespaces but this problems occurs only when I try to make a serialized dictionary with these two types. What am I doing wrong or is it a bug?
Thanks for the reply!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions