コード例 #1
0
        static PropertyInspector()
        {
            void RegisterInspectorControl(Type userControlType, Type targetType, object defaultValue)
            {
                if (userControlType.IsSubclassOf(typeof(BaseInspectorControl)))
                {
                    InspectorTypeMap.Add(targetType, new InspectorType(userControlType, defaultValue));
                }
            }

            RegisterInspectorControl(typeof(FloatInspector), typeof(float), 0.0f);
            RegisterInspectorControl(typeof(BoolInspector), typeof(bool), false);
            RegisterInspectorControl(typeof(ColorInspector), typeof(Color4), Color4.White);
            RegisterInspectorControl(typeof(IntegerInspector), typeof(int), 0);
            RegisterInspectorControl(typeof(StringInspector), typeof(string), "");
            RegisterInspectorControl(typeof(Vector2Inspector), typeof(Vector2), Vector2.Zero);
            RegisterInspectorControl(typeof(Vector3Inspector), typeof(Vector3), Vector3.Zero);
            RegisterInspectorControl(typeof(QuaternionInspector), typeof(Quaternion), Quaternion.Identity);
            RegisterInspectorControl(typeof(TypeInspector), typeof(CKlaxScriptTypeInfo), null);
            RegisterInspectorControl(typeof(TypeInspector), typeof(Type), null);
            RegisterInspectorControl(typeof(SubtypeOfInspector), typeof(SSubtypeOf <>), null);
            RegisterInspectorControl(typeof(HashedNameInspector), typeof(SHashedName), SHashedName.Empty);

            RegisterInspectorControl(typeof(AssetReferenceInspector), typeof(CAssetReference <>), null);
            RegisterInspectorControl(typeof(ListInspector), typeof(List <>), null);
            RegisterInspectorControl(typeof(DictionaryInspector), typeof(Dictionary <,>), null);
        }
コード例 #2
0
        public static bool GetInspectorType(Type objectType, out InspectorType outInspectorType)
        {
            if (InspectorTypeMap.TryGetValue(objectType, out outInspectorType))
            {
                return(true);
            }
            else if (objectType.IsGenericType)
            {
                if (InspectorTypeMap.TryGetValue(objectType.GetGenericTypeDefinition(), out outInspectorType))
                {
                    return(true);
                }
            }
            else if (objectType.IsEnum)
            {
                outInspectorType = EnumInspectorType;
                return(true);
            }

            return(false);
        }