Esempio n. 1
0
        static ITypeGUI GetTypeGUI(System.Type type, FieldInfo fieldInfo)
        {
            if (fieldInfo != null)
            {
                var ha = fieldInfo.GetCustomAttributes(typeof(UnityEngine.HideInInspector), false);
                if (ha != null && ha.Length != 0)
                {
                    return(emptyTypeGUI);
                }
            }

            if (IL.Help.isType(type, typeof(UnityEngine.Object)))
            {
                return(unityObjectGUI);
            }

            if (type.IsEnum)
            {
                return(new EnumType(type));
            }

            if (type == typeof(RefType))
            {
                if (fieldInfo == null)
                {
                    return(emptyTypeGUI);
                }

                var ils = fieldInfo.GetCustomAttribute <ILSerializable>();
                return(new RefTypeEditor(IL.Help.GetTypeByFullName(ils.typeName)));
            }

            var atts = type.GetCustomAttributes(typeof(SmartAttribute), false);

            if (atts != null && atts.Length > 0)
            {
                return(new SmartEditor(type, new AnyType(type, IL.Help.GetSerializeField(type))));
            }

            atts = type.GetCustomAttributes(typeof(CSharpAgent), false);
            if (atts != null && atts.Length > 0)
            {
                return(new CSharpAgentType(type));
            }

#if USE_HOT
            ILRuntimeFieldInfo ilFieldInfo = fieldInfo as ILRuntimeFieldInfo;
            if (ilFieldInfo != null && (type.IsArray || IL.Help.isListType(type)))
            {
                var    isListType = type.IsArray ? false : true;
                int    arrayCount = 0;
                string elementType;
                BinarySerializable.GetElementType(ilFieldInfo.Definition.FieldType, ref arrayCount, out elementType);
                var et = IL.Help.GetType(elementType);
                if (et is ILRuntimeType)
                {
                    return(new ArrayListHot(elementType, arrayCount, isListType));
                }
            }
#endif
            if (type.IsArray)
            {
                var elementType = type.GetElementType();
                var arrayGUI    = new ArrayTypeEditor(type, elementType, Get(elementType, null));
                return(arrayGUI);
            }
            else if (IL.Help.isListType(type))
            {
                System.Type elementType = null;
                if (fieldInfo != null)
                {
                    elementType = IL.Help.GetElementByList(fieldInfo);
                }
                else
                {
                    elementType = type.GetGenericArguments()[0];
                }

                return(new ListTypeEditor(type, elementType, Get(elementType, null)));
            }
            else if (IL.Help.isDictionaryType(type))
            {
                return(new DictionaryTypeEditor(type, fieldInfo));
            }
#if USE_HOT
            if (type is ILRuntimeType)
            {
                if ((type.Name.EndsWith("[]")))
                {
                    return(emptyTypeGUI);
                }

                if (!((ILRuntimeType)type).ILType.TypeDefinition.IsSerializable)
                {
                    return(emptyTypeGUI);
                }
            }
            else
#endif
            {
                if (!type.IsSerializable)
                {
                    return(emptyTypeGUI);
                }
            }

            return(new AnyType(type, IL.Help.GetSerializeField(type)));
        }