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.
Every component wrapper in this crate implements it. A mod can wrap its
own (or the game’s) MonoBehaviour the same way by naming the class.
Required Associated Constants§
Required Methods§
Sourcefn from_object(object: Object) -> Self
fn from_object(object: Object) -> Self
Wraps a managed object known to be of this class.
Provided Methods§
Sourcefn game_object(&self) -> Result<GameObject>
fn game_object(&self) -> Result<GameObject>
Component.gameObject: the game object this component is attached to.
Sourcefn transform(&self) -> Result<Transform>
fn transform(&self) -> Result<Transform>
Component.transform: the transform of this component’s game object.
Sourcefn get_component<U: ComponentType>(&self) -> Result<Option<U>>
fn get_component<U: ComponentType>(&self) -> Result<Option<U>>
GetComponent<U>() on this component’s game object, or None if absent.
Sourcefn is_enabled(&self) -> Result<bool>
fn is_enabled(&self) -> Result<bool>
Whether the component is enabled. For Behaviour-derived components
(MonoBehaviour, Canvas, …); meaningless on a plain Transform.
Sourcefn set_enabled(&self, enabled: bool) -> Result<()>
fn set_enabled(&self, enabled: bool) -> Result<()>
Enables or disables the component (Behaviour.enabled); a disabled
MonoBehaviour gets no Update calls.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".