diff --git a/crates/egui/Cargo.toml b/crates/egui/Cargo.toml index 1920a855..552fe18e 100644 --- a/crates/egui/Cargo.toml +++ b/crates/egui/Cargo.toml @@ -54,6 +54,10 @@ persistence = ["serde", "epaint/serde", "ron"] ## Allow serialization using [`serde`](https://docs.rs/serde). serde = ["dep:serde", "epaint/serde", "accesskit?/serde"] +## Change Vertex layout to be compatible with unity +unity = ["epaint/unity"] + + [dependencies] epaint = { version = "0.20.0", path = "../epaint", default-features = false } diff --git a/crates/epaint/Cargo.toml b/crates/epaint/Cargo.toml index 8f2f9165..6ec81bde 100644 --- a/crates/epaint/Cargo.toml +++ b/crates/epaint/Cargo.toml @@ -63,6 +63,9 @@ mint = ["emath/mint"] ## Allow serialization using [`serde`](https://docs.rs/serde). serde = ["dep:serde", "ahash/serde", "emath/serde", "ecolor/serde"] +## Change Vertex layout to be compatible with unity +unity = [] + [dependencies] emath = { version = "0.20.0", path = "../emath" } ecolor = { version = "0.20.0", path = "../ecolor" } diff --git a/crates/epaint/src/mesh.rs b/crates/epaint/src/mesh.rs index 11d6d51d..09025268 100644 --- a/crates/epaint/src/mesh.rs +++ b/crates/epaint/src/mesh.rs @@ -6,6 +6,7 @@ use emath::*; /// Should be friendly to send to GPU as is. #[repr(C)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[cfg(not(feature = "unity"))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))] pub struct Vertex { @@ -22,6 +23,25 @@ pub struct Vertex { pub color: Color32, // 32 bit } +#[repr(C)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[cfg(feature = "unity")] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))] +pub struct Vertex { + /// Logical pixel coordinates (points). + /// (0,0) is the top left corner of the screen. + pub pos: Pos2, // 64 bit + + /// sRGBA with premultiplied alpha + pub color: Color32, // 32 bit + + /// Normalized texture coordinates. + /// (0, 0) is the top left corner of the texture. + /// (1, 1) is the bottom right corner of the texture. + pub uv: Pos2, // 64 bit +} + /// Textured triangles in two dimensions. #[derive(Clone, Debug, Default, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]