protected virtual Type GetDrawerTypeForComponent([NotNull] Type componentType, out Type customEditorType) { Type drawerType; if (drawersFor.components.TryGetValue(componentType, out drawerType)) { customEditorType = null; return(drawerType); } #if UNITY_EDITOR if (Platform.EditorMode) { if (PluginCompatibilityUtility.UseCompatibilityModeForDisplayingTarget(componentType)) { customEditorType = null; return(typeof(CustomEditorComponentDrawer)); } if (CustomEditorUtility.TryGetCustomEditorType(componentType, out customEditorType)) { return(typeof(CustomEditorComponentDrawer)); } } #endif customEditorType = null; return(typeof(ComponentDrawer)); }
protected virtual Type GetDrawerTypeForAsset([NotNull] Type assetType, [NotNull] string localPath) { Type drawerType; if (localPath.Length > 0) { #if UNITY_EDITOR string fullPath = FileUtility.LocalToFullPath(localPath); if (Directory.Exists(fullPath)) { return(typeof(FolderDrawer)); } #endif string fileExtension = Path.GetExtension(localPath).ToLowerInvariant(); if (fileExtension.Length > 0) { if (drawersFor.assetsByExtension.TryGetValue(fileExtension, out drawerType)) { #if DEV_MODE && DEBUG_GET_FOR_ASSET Debug.Log("GetDrawerTypeForAsset(" + StringUtils.ToString(assetType) + "): " + drawerType.Name + " via extension \"" + fileExtension + "\" with localPath=\"" + localPath + "\""); #endif return(drawerType); } } } if (drawersFor.assets.TryGetValue(assetType, out drawerType)) { #if DEV_MODE && DEBUG_GET_FOR_ASSET Debug.Log("GetDrawerTypeForAsset(" + StringUtils.ToString(assetType) + "): " + drawerType.Name + " via asset type with localPath=\"" + localPath + "\""); #endif return(drawerType); } #if UNITY_EDITOR // ScriptableObjects use AssetDrawers unless using Compatibility mode, in which case always use CustomEditorAssetDrawer if (assetType.IsScriptableObject() && !PluginCompatibilityUtility.UseCompatibilityModeForDisplayingTarget(assetType)) { #if DEV_MODE && DEBUG_GET_FOR_ASSET Debug.Log("GetDrawerTypeForAsset(" + StringUtils.ToString(assetType) + "): AssetDrawer as fallback with localPath=\"" + localPath + "\""); #endif return(typeof(AssetDrawer)); } #if DEV_MODE && DEBUG_GET_FOR_ASSET Debug.Log("GetDrawerTypeForAsset(" + StringUtils.ToString(assetType) + "): CustomEditorAssetDrawer as fallback with localPath=\"" + localPath + "\""); #endif return(typeof(CustomEditorAssetDrawer)); #else return(typeof(AssetDrawer)); #endif }