public bool TryGetComponent (out T component); 参数 type 要获取的组件类型。 component 输出参数将包含组件或 /null/。返回 bool 如果发现组件,则返回 /true/,否则返回 /false/。 描述 获取指定类型的组件(如果存在)。TryGetComponent 将尝试获取给定类型的组件。与 GameObject.GetComponent 相比的显著差异在于,...
问使用TryGetComponent返回<T>的子级EN出现问题的代码: .divcss5{ width:500px; border:1p...
public bool TryGetComponent (out T component); 参数 component 输出参数将包含组件或 /null/。返回 bool 如果发现组件,则返回 /true/,否则返回 /false/。 描述 获取指定类型的组件(如果存在)。TryGetComponent attempts to retrieve the component of the given type. The notable difference compared to ...
获取指定类型的组件(如果存在)。TryGetComponent 将尝试获取给定类型的组件。与 GameObject.GetComponent 相比的显著差异在于,如果请求的组件不存在,则此方法不在编辑器中进行分配。 using UnityEngine;public class TryGetComponentExample : MonoBehaviour { void Start() { if (TryGetComponent(out HingeJoint hinge)) ...
public class TryGetComponentExample : MonoBehaviour { void Start() { if (gameObject.TryGetComponent(typeof(HingeJoint), out Component component)) { component.name = "My Hinge"; } } } public bool TryGetComponent (out T component); 参数 component 输出参数将包含组件或 /null/。
public bool TryGetComponent (out T component); 参数 type 要获取的组件类型。 component 输出参数将包含组件或 /null/。返回 bool 如果发现组件,则返回 /true/,否则返回 /false/。 描述 获取指定类型的组件(如果存在)。TryGetComponent 将尝试获取给定类型的组件。与 GameObject.GetComponent 相比的显著差异在于,...
Component.TryGetComponent public boolTryGetComponent(out Tcomponent); 参数 component输出参数将包含组件或 /null/。 返回 bool如果发现组件,则返回 /true/,否则返回 /false/。 描述 获取指定类型的组件(如果存在)。 TryGetComponent attempts to retrieve the component of the given type. The notable difference ...
public bool TryGetComponent (Type type, out Component component); public bool TryGetComponent (out T component); Parameters type The type of the component to retrieve. component The output argument that will contain the component or null. ...