EZS icon indicating copy to clipboard operation
EZS copied to clipboard

Fix for draw Enum and string

Open Prog-Maker opened this issue 3 years ago • 0 comments

ComponentInspector.cs

 private static void SetFieldValue(object fieldValue, string fieldName, object component)
        {
            if (fieldValue == null) return;
            var fieldType = fieldValue.GetType();
            var baseType = fieldType.BaseType;
            if (inspectors.ContainsKey(fieldType))
            {
                if (typeof(IEnumerable).IsAssignableFrom(fieldType) && fieldType != typeof(string))
                    fieldValue = GetInspector(typeof(IEnumerable)).DrawIn(fieldName, fieldValue);
                else
                    fieldValue = GetInspector(fieldValue.GetType()).DrawIn(fieldName, fieldValue);
            }
            else if (baseType == typeof(System.Enum))
            {
                fieldValue = GetInspector(typeof(System.Enum)).DrawIn(fieldName, fieldValue);
            }

            component.GetType().GetField(fieldName).SetValue(component, fieldValue);
        }

Prog-Maker avatar Aug 20 '22 11:08 Prog-Maker