pub struct TextOverlay { /* private fields */ }Expand description
A line of TextMeshPro text on its own OverlayCanvas, drawn over the game’s
UI and kept across scene loads. Positioned from the top left of the screen.
Create it on Unity’s main thread, e.g. in on_scene_loaded.
Implementations§
Source§impl TextOverlay
impl TextOverlay
Sourcepub fn new(name: &str) -> Result<Self>
pub fn new(name: &str) -> Result<Self>
Creates the overlay on a canvas called name: empty, 28pt, 16 pixels
from the top left.
Sourcepub fn game_object(&self) -> GameObject
pub fn game_object(&self) -> GameObject
The overlay’s canvas game object; destroying it removes the overlay.
Sourcepub fn text(&self) -> TextMeshPro
pub fn text(&self) -> TextMeshPro
The text component, for styling this wrapper doesn’t cover.
Sourcepub fn set_text(&self, text: &str) -> Result<()>
pub fn set_text(&self, text: &str) -> Result<()>
Replaces the displayed text (TextMeshPro rich-text tags are honoured).
Sourcepub fn set_position(&self, x: f32, y: f32) -> Result<()>
pub fn set_position(&self, x: f32, y: f32) -> Result<()>
Pixels from the top left of the screen.
Sourcepub fn set_font_size(&self, size: f32) -> Result<()>
pub fn set_font_size(&self, size: f32) -> Result<()>
The font size in points.
Sourcepub fn set_visible(&self, visible: bool) -> Result<()>
pub fn set_visible(&self, visible: bool) -> Result<()>
Shows or hides the overlay without destroying it.
Auto Trait Implementations§
impl Forget for TextOverlay
impl Freeze for TextOverlay
impl Move for TextOverlay
impl RefUnwindSafe for TextOverlay
impl Send for TextOverlay
impl Sync for TextOverlay
impl Unpin for TextOverlay
impl UnsafeUnpin for TextOverlay
impl UnwindSafe for TextOverlay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more