Skip to main content

ComponentType

Trait ComponentType 

Source
pub trait ComponentType: Il2CppValue {
    const ASSEMBLY: &'static str;
    const NAMESPACE: &'static str;
    const NAME: &'static str;

    // Required methods
    fn from_object(object: Object) -> Self;
    fn object(&self) -> Object;

    // Provided methods
    fn game_object(&self) -> Result<GameObject> { ... }
    fn transform(&self) -> Result<Transform> { ... }
    fn get_component<U: ComponentType>(&self) -> Result<Option<U>> { ... }
    fn is_enabled(&self) -> Result<bool> { ... }
    fn set_enabled(&self, enabled: bool) -> Result<()> { ... }
}
Expand description

A component type, for GameObject::add_component.

Required Associated Constants§

Source

const ASSEMBLY: &'static str

Source

const NAMESPACE: &'static str

Source

const NAME: &'static str

Required Methods§

Source

fn from_object(object: Object) -> Self

Source

fn object(&self) -> Object

Provided Methods§

Source

fn game_object(&self) -> Result<GameObject>

Source

fn transform(&self) -> Result<Transform>

Source

fn get_component<U: ComponentType>(&self) -> Result<Option<U>>

GetComponent<U>() on this component’s game object, or None if absent.

Source

fn is_enabled(&self) -> Result<bool>

Whether the component is enabled. For Behaviour-derived components (MonoBehaviour, Canvas, …); meaningless on a plain Transform.

Source

fn set_enabled(&self, enabled: bool) -> Result<()>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ComponentType for Camera

Source§

const ASSEMBLY: &'static str = "UnityEngine.CoreModule"

Source§

const NAMESPACE: &'static str = "UnityEngine"

Source§

const NAME: &'static str = "Camera"

Source§

impl ComponentType for Canvas

Source§

const ASSEMBLY: &'static str = "UnityEngine.UIModule"

Source§

const NAMESPACE: &'static str = "UnityEngine"

Source§

const NAME: &'static str = "Canvas"

Source§

impl ComponentType for Component

Source§

const ASSEMBLY: &'static str = "UnityEngine.CoreModule"

Source§

const NAMESPACE: &'static str = "UnityEngine"

Source§

const NAME: &'static str = "Component"

Source§

impl ComponentType for RawImage

Source§

const ASSEMBLY: &'static str = "UnityEngine.UI"

Source§

const NAMESPACE: &'static str = "UnityEngine.UI"

Source§

const NAME: &'static str = "RawImage"

Source§

impl ComponentType for RectTransform

Source§

const ASSEMBLY: &'static str = "UnityEngine.CoreModule"

Source§

const NAMESPACE: &'static str = "UnityEngine"

Source§

const NAME: &'static str = "RectTransform"

Source§

impl ComponentType for TextMeshPro

Source§

const ASSEMBLY: &'static str = "Unity.TextMeshPro"

Source§

const NAMESPACE: &'static str = "TMPro"

Source§

const NAME: &'static str = "TextMeshProUGUI"

Source§

impl ComponentType for Transform

Source§

const ASSEMBLY: &'static str = "UnityEngine.CoreModule"

Source§

const NAMESPACE: &'static str = "UnityEngine"

Source§

const NAME: &'static str = "Transform"