I made a ProfileState class to store a guid string, and also a Dictionary with key string and value ProfileState.
[System.Serializable]
public class ProfileState
{
public string guid;
public static Dictionary<string, ProfileState> profileStateDictionary = new Dictionary<string, ProfileState>();
public Profile profileData;
}
But when I try to create a generic Dictionary and set a Profile State Dictionary, I get a type mismatch error:
InvalidConversionException: Cannot convert from ‘Unity.VisualScripting.AotDictionary’ to ‘System.Collections.Generic.Dictionary`2[System.String,ProfileState]’.
Unity.VisualScripting.ConversionUtility.Convert (System.Object value, System.Type type, Unity.VisualScripting.ConversionUtility+ConversionType conversionType)
I see from the error that you can’t create a Generic Dictionary and set it equal to a Profile State Dictionary.
I ended up writing a Custom Node that creates a string/ProfileState dictionary for me, and that seemed to resolve the issue:
Is this the best approach though? I would have to create a Custom Node every time I wanted to make a dictionary for a different type of State. I also have to make Custom Nodes to Add and Remove Dictionary Items for each State type. Just feels like a bit of kludge.
I could make a Generic Dictionary and then store that data in a scene variable, but I was hoping to use the Profile State custom class.
Is there an easy way use Unity Visual Scripting to make a Generic Dictionary, and still store the data inside of a custom class?