 de004da8d5
			
		
	
	
		de004da8d5
		
			
		
	
	
	
	
		
			
			# Objective The migration process for `bevy_color` (#12013) will be fairly involved: there will be hundreds of affected files, and a large number of APIs. ## Solution To allow us to proceed granularly, we're going to keep both `bevy_color::Color` (new) and `bevy_render::Color` (old) around until the migration is complete. However, simply doing this directly is confusing! They're both called `Color`, making it very hard to tell when a portion of the code has been ported. As discussed in #12056, by renaming the old `Color` type, we can make it easier to gradually migrate over, one API at a time. ## Migration Guide THIS MIGRATION GUIDE INTENTIONALLY LEFT BLANK. This change should not be shipped to end users: delete this section in the final migration guide! --------- Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
		
			
				
	
	
		
			35 lines
		
	
	
		
			879 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			879 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //! This example demonstrates how to use the `Camera::viewport_to_world_2d` method.
 | |
| 
 | |
| use bevy::prelude::*;
 | |
| 
 | |
| fn main() {
 | |
|     App::new()
 | |
|         .add_plugins(DefaultPlugins)
 | |
|         .add_systems(Startup, setup)
 | |
|         .add_systems(Update, draw_cursor)
 | |
|         .run();
 | |
| }
 | |
| 
 | |
| fn draw_cursor(
 | |
|     camera_query: Query<(&Camera, &GlobalTransform)>,
 | |
|     windows: Query<&Window>,
 | |
|     mut gizmos: Gizmos,
 | |
| ) {
 | |
|     let (camera, camera_transform) = camera_query.single();
 | |
| 
 | |
|     let Some(cursor_position) = windows.single().cursor_position() else {
 | |
|         return;
 | |
|     };
 | |
| 
 | |
|     // Calculate a world position based on the cursor's position.
 | |
|     let Some(point) = camera.viewport_to_world_2d(camera_transform, cursor_position) else {
 | |
|         return;
 | |
|     };
 | |
| 
 | |
|     gizmos.circle_2d(point, 10., LegacyColor::WHITE);
 | |
| }
 | |
| 
 | |
| fn setup(mut commands: Commands) {
 | |
|     commands.spawn(Camera2dBundle::default());
 | |
| }
 |