示例#1
0
        private void CacheColorPicker()
        {
            if (_sliderModeMemberInfo != null)
            {
                return;
            }

            var colorPickerType = typeof(EditorApplication)
                                  .Assembly.GetType("UnityEditor.ColorPicker");

            var cachedType = mCore.GetCachedType(colorPickerType);

            foreach (var cachedField in cachedType.CachedFields)
            {
                Debug.Log($"asd = {cachedField.FieldInfo.Name}");
            }

            _sliderModeMemberInfo = cachedType.CachedFields.First(f => f.FieldInfo.Name == "m_SliderMode");
        }
示例#2
0
        private void CacheProperty(SerializedProperty property)
        {
            if (_memberInfo != null && _target != null)
            {
                return;
            }

            _target     = property.serializedObject.targetObject;
            _memberInfo = null;
            var path = property.propertyPath.Split('.');

            for (var i = 0; i < path.Length; i++)
            {
                var cachedType = mCore.GetCachedType(_target.GetType());
                _memberInfo = cachedType.GetFieldOrProperty(path[i]);
                var value = _memberInfo.GetValue(_target);

                if (i + 1 < path.Length)
                {
                    _target = value;
                }
            }
        }
示例#3
0
        public bool Refresh()
        {
            ITypeId     typeId      = this.baseType;
            IPropertyId propertyId  = this.nameProperty;
            IPropertyId propertyId1 = this.defaultContentProperty;
            ITypeId     typeId1     = this.itemType;
            ITypeId     typeId2     = this.nullableType;

            System.ComponentModel.TypeConverter typeConverter = this.typeConverter;
            IAssembly assembly = this.GetAssembly(this.typeResolver, this.assemblyName);

            if (!assembly.IsLoaded)
            {
                return(true);
            }
            this.assembly                = assembly;
            this.type                    = this.GetRuntimeType();
            this.typeConverter           = null;
            this.initializationException = null;
            if (this.type != null)
            {
                this.lastResolvedType = this.type;
                this.isBuilt          = true;
            }
            this.Cache();
            bool flag = true;

            if (this.constructors != null)
            {
                foreach (Constructor constructor in this.constructors)
                {
                    ICachedMemberInfo cachedMemberInfo = constructor;
                    if (cachedMemberInfo == null || cachedMemberInfo.Refresh())
                    {
                        continue;
                    }
                    flag = false;
                }
                if (flag && this.type != null)
                {
                    int num = 0;
                    ConstructorInfo[] constructors = PlatformTypeHelper.GetConstructors(this.type);
                    if (constructors != null)
                    {
                        ConstructorInfo[] constructorInfoArray = constructors;
                        for (int i = 0; i < (int)constructorInfoArray.Length; i++)
                        {
                            if (PlatformTypeHelper.IsAccessibleConstructor(constructorInfoArray[i]))
                            {
                                num++;
                            }
                        }
                    }
                    if (num != this.constructors.Count)
                    {
                        flag = false;
                    }
                }
            }
            if (!this.members.Refresh())
            {
                flag = false;
            }
            if (flag && (typeId != this.baseType || typeId1 != this.itemType || typeId2 != this.nullableType))
            {
                flag = false;
            }
            if (flag && (propertyId != this.nameProperty || propertyId1 != this.defaultContentProperty))
            {
                flag = false;
            }
            if (flag && ProjectContextType.GetTypeConverterId(typeConverter) != ProjectContextType.GetTypeConverterId(this.typeConverter))
            {
                flag = false;
            }
            if (flag && this.constructorArgumentProperties != null)
            {
                IConstructorArgumentProperties constructorArgumentProperties = PlatformTypeHelper.GetConstructorArgumentProperties(this);
                if (constructorArgumentProperties.Count == this.constructorArgumentProperties.Count)
                {
                    foreach (string constructorArgumentProperty in constructorArgumentProperties)
                    {
                        if (constructorArgumentProperties[constructorArgumentProperty] == this.constructorArgumentProperties[constructorArgumentProperty])
                        {
                            continue;
                        }
                        flag = false;
                        break;
                    }
                }
                else
                {
                    flag = false;
                }
            }
            return(flag);
        }