private void ContentImporting_ImportFileDone(IFileEntryAction obj, bool failed) { if (failed) { return; } // Check if already has that element var item = Find(obj.ResultUrl); if (item is BinaryAssetItem binaryAssetItem) { // Get asset info from the registry (content layer will update cache it just after import) if (FlaxEngine.Content.GetAssetInfo(binaryAssetItem.Path, out var assetInfo)) { // If asset type id has been changed we HAVE TO close all windows that use it // For eg. change texture to sprite atlas on reimport if (binaryAssetItem.TypeName != assetInfo.TypeName) { // Asset type has been changed! Editor.LogWarning(string.Format("Asset \'{0}\' changed type from {1} to {2}", item.Path, binaryAssetItem.TypeName, assetInfo.TypeName)); Editor.Windows.CloseAllEditors(item); // Remove this item from the database and some related data var toRefresh = binaryAssetItem.ParentFolder; binaryAssetItem.Dispose(); toRefresh.Children.Remove(binaryAssetItem); if (!binaryAssetItem.HasDefaultThumbnail) { // Delete old thumbnail and remove it from the cache Editor.Instance.Thumbnails.DeletePreview(binaryAssetItem); } // Refresh the parent folder to find the new asset (it should have different type or some other format) RefreshFolder(toRefresh, false); } else { // Refresh element data that could change during importing binaryAssetItem.OnReimport(ref assetInfo.ID); } } // Refresh content view (not the best design because window could also track this event but it gives better performance) Editor.Windows.ContentWin?.RefreshView(); } }
private void ContentImporting_ImportFileDone(IFileEntryAction obj, bool failed) { if (failed) { return; } // Check if already has that element var item = Find(obj.ResultUrl); if (item is BinaryAssetItem binaryAssetItem) { // Get asset info from the registry (content layer will update cache it just after import) string typeName; Guid id; if (FlaxEngine.Content.GetAssetInfo(binaryAssetItem.Path, out typeName, out id)) { // If asset type id has been changed we HAVE TO close all windows that use it // For eg. change texture to sprite atlas on reimport if (binaryAssetItem.TypeName != typeName) { // Asset type has been changed! Editor.LogWarning(string.Format("Asset \'{0}\' changed type from {1} to {2}", item.Path, binaryAssetItem.TypeName, typeName)); Editor.Windows.CloseAllEditors(item); // Remove this item from the database and call refresh var toRefresh = binaryAssetItem.ParentFolder; binaryAssetItem.Dispose(); RefreshFolder(toRefresh, false); } else { // Refresh element data that could change during importing binaryAssetItem.OnReimport(ref id); } } } }