文档

Unity Engine

Unity Engine

GetComponent<T>()

Returns a component of type T. For PlayerSettings, returns the global fallback if no PlayerSettings component is found. Returns null if the component isn't available.
阅读时间1 分钟最后更新于 14 天前

Definition

public T GetComponent<T>() where T : Object

Returns

Type

Description

TA component of type
T
or
null
if the component isn't available.

Remarks

For BuildProfilePlayerSettings, returns
null
if the build profile uses the global Player settings. To get the Player settings that apply in either case, call this method with PlayerSettings as
T
.
Note: This method is restricted to ScriptableObject types, PlayerSettings, and BuildProfilePlayerSettings.