Skip to content

Commit b738f08

Browse files
Register reflect type CursorIcon (#15078)
# Objective - `CursorIcon` had derived `Reflect`, but it wasn't registered ## Solution - Use `register_type` on it - I also moved the cursor code to it's own plugin because there was starting to be too much cursor code outside the cursor file. ## Testing - window_settings example still works with the custom cursor
1 parent bbecc05 commit b738f08

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

crates/bevy_render/src/view/window/cursor.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use bevy_app::{App, Last, Plugin};
12
use bevy_asset::{AssetId, Assets, Handle};
23
use bevy_ecs::{
34
change_detection::DetectChanges,
@@ -19,6 +20,16 @@ use wgpu::TextureFormat;
1920

2021
use crate::prelude::Image;
2122

23+
pub struct CursorPlugin;
24+
25+
impl Plugin for CursorPlugin {
26+
fn build(&self, app: &mut App) {
27+
app.register_type::<CursorIcon>()
28+
.init_resource::<CustomCursorCache>()
29+
.add_systems(Last, update_cursors);
30+
}
31+
}
32+
2233
/// Insert into a window entity to set the cursor for that window.
2334
#[derive(Component, Debug, Clone, Reflect, PartialEq, Eq)]
2435
#[reflect(Component, Debug, Default)]

crates/bevy_render/src/view/window/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use crate::{
33
renderer::{RenderAdapter, RenderDevice, RenderInstance},
44
Extract, ExtractSchedule, Render, RenderApp, RenderSet, WgpuWrapper,
55
};
6-
use bevy_app::{App, Last, Plugin};
6+
use bevy_app::{App, Plugin};
77
use bevy_ecs::{entity::EntityHashMap, prelude::*};
88
#[cfg(target_os = "linux")]
99
use bevy_utils::warn_once;
1010
use bevy_utils::{default, tracing::debug, HashSet};
1111
use bevy_window::{
1212
CompositeAlphaMode, PresentMode, PrimaryWindow, RawHandleWrapper, Window, WindowClosing,
1313
};
14-
use bevy_winit::CustomCursorCache;
14+
use cursor::CursorPlugin;
1515
use std::{
1616
num::NonZero,
1717
ops::{Deref, DerefMut},
@@ -23,16 +23,13 @@ use wgpu::{
2323
pub mod cursor;
2424
pub mod screenshot;
2525

26-
use self::cursor::update_cursors;
2726
use screenshot::{ScreenshotPlugin, ScreenshotToScreenPipeline};
2827

2928
pub struct WindowRenderPlugin;
3029

3130
impl Plugin for WindowRenderPlugin {
3231
fn build(&self, app: &mut App) {
33-
app.add_plugins(ScreenshotPlugin)
34-
.init_resource::<CustomCursorCache>()
35-
.add_systems(Last, update_cursors);
32+
app.add_plugins((ScreenshotPlugin, CursorPlugin));
3633

3734
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
3835
render_app

0 commit comments

Comments
 (0)