Skip to main content

Camera

Struct Camera 

Source
#[repr(C)]
pub struct Camera { pub component: Component, }

Fields§

§component: Component

Base Component structure

Implementations§

Source§

impl Camera

Source

pub fn get_class() -> Option<Class>

Gets the Camera class definition

§Returns
  • Option<Class> - The UnityEngine.Camera class
Source

pub fn get_main() -> Result<Option<Camera>, String>

Gets the main camera in the scene (Camera.main)

§Returns
  • Result<Option<Camera>, String> - The main camera if it exists
Source

pub fn get_current() -> Result<Option<Camera>, String>

Gets the current camera (for rendering events)

§Returns
  • Result<Option<Camera>, String> - The current camera if it exists
Source

pub fn get_all_count() -> Result<i32, String>

Gets the count of all active cameras

§Returns
  • Result<i32, String> - The number of all cameras enabled in the scene
Source

pub fn get_all_cameras() -> Result<Vec<Camera>, String>

Gets a list of all active cameras

§Returns
  • Result<Vec<Camera>, String> - A vector containing all active cameras
Source

pub fn get_depth(&self) -> Result<f32, String>

Gets the depth of the camera

§Returns
  • Result<f32, String> - The camera’s depth in the rendering order
Source

pub fn set_depth(&self, depth: f32) -> Result<(), String>

Sets the depth of the camera

§Arguments
  • depth - The new depth value
§Returns
  • Result<(), String> - Ok if success
Source

pub fn get_field_of_view(&self) -> Result<f32, String>

Gets the field of view of the camera

§Returns
  • Result<f32, String> - The field of view in degrees
Source

pub fn set_field_of_view(&self, fov: f32) -> Result<(), String>

Sets the field of view of the camera

§Arguments
  • fov - The new field of view in degrees
§Returns
  • Result<(), String> - Ok if success
Source

pub fn world_to_screen_point( &self, position: Vector3, eye: CameraEye, ) -> Result<Vector3, String>

Converts a point from world space to screen space

§Arguments
  • position - The world position to convert
  • eye - The camera eye to use for conversion
§Returns
  • Result<Vector3, String> - The screen point
Source

pub fn screen_to_world_point( &self, position: Vector3, eye: CameraEye, ) -> Result<Vector3, String>

Converts a point from screen space to world space

§Arguments
  • position - The screen position to convert
  • eye - The camera eye to use for conversion
§Returns
  • Result<Vector3, String> - The world point
Source

pub fn camera_to_world_matrix(&self) -> Result<Matrix4x4, String>

Gets the camera to world matrix

§Returns
  • Result<Matrix4x4, String> - The matrix that transforms from camera space to world space
Source

pub fn world_to_screen( &self, position: Vector3, eye: CameraEye, ) -> Result<(Vector2, bool), String>

Converts world position to screen coordinates and checks if it’s on screen

§Arguments
  • position - The world position
  • eye - The camera eye
§Returns
  • Result<(Vector2, bool), String> - A tuple of (screen position, is on screen)
Source

pub fn screen_point_to_ray( &self, position: Vector2, eye: CameraEye, ) -> Result<Ray, String>

Returns a ray from the camera through a screen point

§Arguments
  • position - The screen position
  • eye - The camera eye
§Returns
  • Result<Ray, String> - The ray passing through the screen point

Methods from Deref<Target = Component>§

Source

pub fn as_ptr(&self) -> *mut c_void

Returns the raw managed pointer.

Source

pub fn get_game_object(&self) -> Result<GameObject, String>

Returns the GameObject attached to this component.

Source

pub fn get_transform(&self) -> Result<Transform, String>

Returns the Transform attached to this component.

Source

pub fn get_component<T: ComponentTrait>( &self, class: &Class, ) -> Result<T, String>

Resolves another component of the specified class on the same GameObject.

Methods from Deref<Target = UnityObject>§

Source

pub fn as_ptr(&self) -> *mut c_void

Returns the raw managed pointer.

Source

pub fn get_name(&self) -> Result<String, String>

Returns the Unity object name.

Source

pub fn to_string(&self) -> Result<String, String>

Returns the managed ToString() representation.

Source

pub fn destroy(&self, time_delay: f32) -> Result<(), String>

Schedules this object for destruction after time_delay seconds.

Methods from Deref<Target = Object>§

Source

pub fn as_ptr(&self) -> *mut c_void

Returns the raw pointer to the object

§Returns
  • *mut c_void - The raw pointer
Source

pub fn field(&self, name: &str) -> Option<Field>

Returns an instance-bound field lookup.

The returned Field carries this object’s instance pointer so Field::get_value and Field::set_value can operate on it.

Source

pub fn method<S: MethodSelector>(&self, selector: S) -> Option<Method>

Returns an instance-bound method lookup.

This is the preferred way to prepare instance method calls because the returned Method already carries the correct this pointer.

Source

pub fn property(&self, name: &str) -> Option<Property>

Returns an instance-bound property lookup.

Source

pub fn il2cpp_to_string(&self) -> String

Calls ToString on the object

§Returns
  • String - The string representation, or “null” if failed
Source

pub fn get_game_object(&self) -> Result<GameObject, String>

Gets the GameObject associated with this object (if Is a Component)

§Returns
  • Result<GameObject, String> - The GameObject, or an error if null/not found
Source

pub fn get_class(&self) -> Option<Class>

Gets the class of this object

§Returns
  • Option<Class> - The class definition, or None if failed
Source

pub fn get_virtual_method(&self, method: &Method) -> *mut c_void

Gets the virtual method implementation for this object

§Arguments
  • method - The method definition to resolve
§Returns
  • *mut c_void - Pointer to the implementation
Source

pub fn init_exception(&self, exc: &mut c_void)

Initializes an exception object

§Arguments
  • exc - Pointer to the exception object
Source

pub fn get_size(&self) -> u32

Gets the size of the object

§Returns
  • u32 - Size in bytes
Source

pub fn unbox(&self) -> *mut c_void

Unboxes a value type object

§Returns
  • *mut c_void - Pointer to the unboxed value

Trait Implementations§

Source§

impl Clone for Camera

Source§

fn clone(&self) -> Camera

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ComponentTrait for Camera

Source§

fn from_ptr(ptr: *mut c_void) -> Self

Creates the wrapper from a raw managed object pointer.
Source§

impl Debug for Camera

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Camera

Source§

type Target = Component

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Copy for Camera

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.