Skip to main content

GameObject.TryGetComponent(TComponent type)

Gets the component of the specified type, if it exists.

Parameters:

NameTypeDescription
typeTComponentThe type of component to retrieve.

Returns:

typeDescription
booleanReturns true if the component is found, false otherwise.
TComponentThe output argument that will contain the component or null.

Usage

---@type GameObject
local gameobject;

---@type TComponent
local type;


local val0, val1 = gameobject.TryGetComponent(type)