Skip to content

Commit

Permalink
Add CameraRenderGraph::set (#6470)
Browse files Browse the repository at this point in the history
# Objective

Some render plugins, like [bevy-hikari](https://github.com/cryscan/bevy-hikari) require to set `CameraRenderGraph`. In order to switch between render graphs I need to insert a new `CameraRenderGraph` component. It's not very ergonomic.

## Solution

Add `CameraRenderGraph::set` like in [Name](https://docs.rs/bevy/latest/bevy/core/struct.Name.html).

---

## Changelog

### Added

- `CameraRenderGraph::set`.
  • Loading branch information
Shatur committed Nov 6, 2022
1 parent feebbc5 commit efc111c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/bevy_render/src/camera/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,17 @@ impl Camera {
pub struct CameraRenderGraph(Cow<'static, str>);

impl CameraRenderGraph {
/// Creates a new [`CameraRenderGraph`] from any string-like type.
#[inline]
pub fn new<T: Into<Cow<'static, str>>>(name: T) -> Self {
Self(name.into())
}

#[inline]
/// Sets the graph name.
pub fn set<T: Into<Cow<'static, str>>>(&mut self, name: T) {
self.0 = name.into();
}
}

/// The "target" that a [`Camera`] will render to. For example, this could be a [`Window`](bevy_window::Window)
Expand Down

0 comments on commit efc111c

Please sign in to comment.