コード例 #1
0
        public static PropertyContentDrawer CreateCustomTypeDrawer(DrawerProperty property)
        {
            Type type = GetReallyDrawerType(property.ValueType);

            if (customTypeDrawerDic.TryGetValue(type, out Type drawerType))
            {
                PropertyContentDrawer drawer = (PropertyContentDrawer)Activator.CreateInstance(drawerType);
                drawer.Property = property;

                return(drawer);
            }

            return(null);
        }
コード例 #2
0
        internal void Init()
        {
            if (!IsArrayElement)
            {
                var drawerAttrs = Field.GetCustomAttributes <DrawerAttribute>();
                foreach (var attr in drawerAttrs)
                {
                    var drawer = DrawerUtility.CreateAttrDrawer(this, attr);
                    if (drawer == null)
                    {
                        Debug.LogWarning("DrawerProperty::Init->drawer not found.attr = " + attr.GetType().Name);
                    }
                    else
                    {
                        if (drawer.GetType().IsSubclassOf(typeof(DecoratorDrawer)))
                        {
                            decoratorDrawers.Add(drawer as DecoratorDrawer);
                        }
                        else if (drawer.GetType().IsSubclassOf(typeof(LayoutDrawer)))
                        {
                            layoutDrawers.Add(drawer as LayoutDrawer);
                        }
                        else if (drawer.GetType().IsSubclassOf(typeof(ListenerDrawer)))
                        {
                            listenerDrawers.Add(drawer as ListenerDrawer);
                        }
                        else if (drawer.GetType().IsSubclassOf(typeof(PropertyControlDrawer)))
                        {
                            controlDrawers.Add(drawer as PropertyControlDrawer);
                        }
                        else if (drawer.GetType().IsSubclassOf(typeof(VisibleDrawer)))
                        {
                            visibleDrawers.Add(drawer as VisibleDrawer);
                        }
                        else if (drawer.GetType().IsSubclassOf(typeof(VerificationDrawer)))
                        {
                            verificationDrawers.Add(drawer as VerificationDrawer);
                        }
                        else if (drawer.GetType().IsSubclassOf(typeof(PropertyLabelDrawer)))
                        {
                            if (labelDrawer != null)
                            {
                                Debug.LogWarning("DrawerProperty::Init->labelDrawer has been found.attr = " + attr.GetType().Name);
                            }
                            else
                            {
                                labelDrawer = drawer as PropertyLabelDrawer;
                            }
                        }
                        else if (drawer.GetType().IsSubclassOf(typeof(PropertyContentDrawer)))
                        {
                            if (contentDrawer != null)
                            {
                                Debug.LogWarning("DrawerProperty::Init->contentDrawer has been found.attr = " + attr.GetType().Name);
                            }
                            else
                            {
                                contentDrawer = drawer as PropertyContentDrawer;
                            }
                        }
                    }
                }
            }

            if (contentDrawer == null)
            {
                contentDrawer = DrawerUtility.CreateCustomTypeDrawer(this);
                if (contentDrawer == null)
                {
                    if (DrawerUtility.IsTypeSupported(ValueType))
                    {
                        if (ValueType.IsStructOrClassType() && Value != null)
                        {
                            drawerObject = new DrawerObject(Value);
                        }
                    }
                }
            }
        }