Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bevy_editor_panes/bevy_asset_browser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2024"

[dependencies]
bevy.workspace = true
bevy_asset_preview.workspace = true
bevy_editor_styles.workspace = true
bevy_pane_layout.workspace = true
bevy_scroll_box.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions bevy_editor_panes/bevy_asset_browser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use bevy::{
},
prelude::*,
};
use bevy_asset_preview::AssetPreviewPlugin;
use bevy_pane_layout::prelude::*;
use bevy_scroll_box::ScrollBoxPlugin;
use ui::top_bar::location_as_changed;
Expand Down Expand Up @@ -69,6 +70,8 @@ impl Plugin for AssetBrowserPanePlugin {
)
.run_if(location_as_changed),
);

app.add_plugins(AssetPreviewPlugin);
}
}

Expand Down
3 changes: 2 additions & 1 deletion bevy_editor_panes/bevy_asset_browser/src/ui/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use bevy::{
prelude::*,
window::SystemCursorIcon,
};
use bevy_asset_preview::PreviewAsset;
use bevy_context_menu::{ContextMenu, ContextMenuOption};
use bevy_editor_styles::Theme;

Expand Down Expand Up @@ -177,7 +178,7 @@ pub(crate) fn spawn_file_node<'a>(

// Icon
commands.spawn((
ImageNode::new(asset_server.load("embedded://bevy_asset_browser/assets/file_icon.png")),
PreviewAsset(location.path.join(&file_name)),
Node {
height: Val::Px(50.0),
..default()
Expand Down
9 changes: 8 additions & 1 deletion crates/bevy_asset_preview/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ version = "0.1.0"
edition = "2024"

[dependencies]
bevy.workspace = true
bevy = { workspace = true, features = ["webp"] }
image = "0.25"
thiserror.workspace = true

[dev-dependencies]
tempfile = "3"
gltf = "1"
bytemuck = "1"
41 changes: 41 additions & 0 deletions crates/bevy_asset_preview/src/asset/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use std::path::PathBuf;

use bevy::{
asset::AssetPath,
prelude::{Handle, Image},
};
use thiserror::Error;

/// Errors that can occur during asset operations.
#[derive(Error, Debug, Clone)]
pub enum AssetError {
#[error("Image not found: {handle:?}")]
ImageNotFound { handle: Handle<Image> },

#[error("Failed to convert image to dynamic format: {0}")]
ImageConversionFailed(String),

#[error("Failed to encode image to {format}: {reason}")]
ImageEncodeFailed { format: String, reason: String },

#[error("Failed to create directory {path:?}: {reason}")]
DirectoryCreationFailed { path: PathBuf, reason: String },

#[error("Failed to write file to {path:?}: {reason}")]
FileWriteFailed { path: PathBuf, reason: String },

#[error("Asset load failed for {path:?}: {reason}")]
AssetLoadFailed {
path: AssetPath<'static>,
reason: String,
},

#[error("Asset was removed (possibly failed to load): {path:?}")]
AssetRemoved { path: AssetPath<'static> },

#[error("IO error: {0}")]
Io(String),

#[error("Asset writer error: {0}")]
AssetWriter(String),
}
Loading