SuperTiled2Unity icon indicating copy to clipboard operation
SuperTiled2Unity copied to clipboard

FindXXXBySignature problem with Enums

Open willyx78 opened this issue 1 year ago • 0 comments

Hi, i'm trying to use int Enums in Tiled for custom properties for Prefab Replacement and they don't work. The problem is that Enum are int32 in Tiled, but in Unity they are...well. enums (type like MyCustomEnumName+Value) and FindPropertyBySignature FindMethodBySignature FindFieldBySignature cannot match the types.

U can fix FindFieldBySignature adding an || (info.FieldType.IsEnum && valueType== Type.GetType("System.Int32"))) To the check of valueType:

private static FieldInfo FindFieldBySignature(Component component, string name, Type valueType) { return component.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public).Where( info => !info.IsInitOnly && info.Name == name && (info.FieldType == valueType || (info.FieldType.IsEnum && valueType== Type.GetType("System.Int32"))) ).FirstOrDefault(); }

Same thing with other 2 Find

willyx78 avatar Nov 28 '23 09:11 willyx78