Exemplo n.º 1
0
        public List <FieldInfo> GetReferenceFieldsForType(Type componentType)
        {
            List <FieldInfo> resultFields = new List <FieldInfo>();

            FieldInfo[] fields = componentType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            foreach (var field in fields)
            {
                //ignore exposed configuration asset
                if (field.FieldType == typeof(ExposedConfiguration))
                {
                    continue;
                }

                if (((field.IsPrivate && Attribute.IsDefined(field, typeof(SerializeField))) ||
                     (field.IsPublic))
                    //nesmi se zaroven jednat o readonly promennou a konstantu
                    && (!field.IsInitOnly) && (!field.IsLiteral))
                {
                    if (field.FieldType.IsSubclassOf(typeof(UnityEngine.Object)))
                    {
                        resultFields.Add(field);
                    }
                    //arrayfield
                    else if (_arrayTypeUtils.IsSupportedArrayType(field.FieldType) &&
                             _arrayTypeUtils.GetElementTypeFromArray(field.FieldType)
                             .IsSubclassOf(typeof(UnityEngine.Object)))
                    {
                        resultFields.Add(field);
                    }
                }
            }

            return(resultFields);
        }
Exemplo n.º 2
0
        private void ProcessField(FieldInfo field, Component affectedComponent, ExposedConfiguration configuration)
        {
            ExposedPropertyConfiguration propertyConfiguration = configuration.ScriptConfigurationManager.GetPropertyConfiguration(field.Name);

            if (propertyConfiguration.Enabled)
            {
                //singlefield
                if (!_arrayTypeUtils.IsSupportedArrayType(field.FieldType))
                {
                    _propertyProcessorManager.ProcessSingleFieldWithProcessor(propertyConfiguration,
                                                                              affectedComponent, field, field.FieldType);
                }
                //arrayfield
                else
                {
                    _propertyProcessorManager.ProcessArrayFieldWithProcessor(propertyConfiguration,
                                                                             affectedComponent, field, _arrayTypeUtils.GetElementTypeFromArray(field.FieldType));
                }
            }
        }