public static GhostFieldAttribute GetGhostFieldAttribute(Mono.Cecil.TypeReference parentType, Mono.Cecil.FieldDefinition componentField)
        {
            if (GhostAuthoringComponentEditor.GhostDefaultOverrides.TryGetValue(parentType.FullName.Replace('/', '+'), out var newComponent))
            {
                foreach (var field in newComponent.fields)
                {
                    if (field.name == componentField.Name)
                    {
                        return(field.attribute);
                    }
                }
                return(default(GhostFieldAttribute));
            }

            var attribute = componentField.GetAttribute <GhostFieldAttribute>();

            if (attribute != null)
            {
                var fieldAttribute = new GhostFieldAttribute();
                if (attribute.HasProperties)
                {
                    foreach (var a in attribute.Properties)
                    {
                        typeof(GhostFieldAttribute).GetProperty(a.Name)?.SetValue(fieldAttribute, a.Argument.Value);
                    }
                }

                return(fieldAttribute);
            }
            return(default(GhostFieldAttribute));
        }
Esempio n. 2
0
        public static GhostFieldAttribute GetGhostFieldAttribute(Mono.Cecil.TypeReference parentType,
                                                                 Mono.Cecil.FieldDefinition componentField)
        {
            var attribute = componentField.GetAttribute <GhostFieldAttribute>();

            if (attribute != null)
            {
                var fieldAttribute = new GhostFieldAttribute();
                if (attribute.HasProperties)
                {
                    foreach (var a in attribute.Properties)
                    {
                        typeof(GhostFieldAttribute).GetProperty(a.Name)?.SetValue(fieldAttribute, a.Argument.Value);
                    }
                }

                return(fieldAttribute);
            }

            return(default(GhostFieldAttribute));
        }