private Type GetType(SerializedProperty property)
        {
            if (typeCache.TryGetValue(property.propertyPath, out Type type) == false)
            {
                Type      propertyType   = property.GetSerializedPropertyType();
                object    propertyObject = Activator.CreateInstance(propertyType);
                LazyAsset lazyAsset      = propertyObject as LazyAsset;

                type = lazyAsset.Type;
                typeCache.Add(property.propertyPath, type);
            }

            return(type);
        }
예제 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty assetGuid = property.FindPropertyRelative("assetGuid");

            var currentValue = this.GetAsset(assetGuid.stringValue);
            var newValue     = EditorGUI.ObjectField(position, label, currentValue, typeof(T), false);

            if (currentValue != newValue)
            {
                assetGuid.stringValue = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(newValue));

                SerializedProperty assetPath = property.FindPropertyRelative("assetPath");
                assetPath.stringValue = AssetDatabase.GUIDToAssetPath(assetGuid.stringValue);

                SerializedProperty assetAssetBundleName = property.FindPropertyRelative("assetBundleName");
                assetAssetBundleName.stringValue = LazyAsset <Object> .FindAssetBundleName(assetPath.stringValue);
            }
        }