JavaScript => GetComponentInParent(type: Type): Component;
C# => Component GetComponentInParent(Type type);
Parameters 参数
type
Type of component to find. 查找组件的类型
Description 描述
Finds component in the parent.
从父对象查找组件。
Recurses upwards till it finds a valid component. Returns null if no component found.
向上递归直到找到一个有效的组件,否则返回空。
JavaScript:
// Disable the spring of the first HingeJoint component
// found on any parent object.
var hinge : HingeJoint;
hinge = gameObject.GetComponentInParent(HingeJoint);
hinge.useSpring = false;
C#:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public HingeJoint hinge;
void Example() {
hinge = gameObject.GetComponentInParent();
hinge.useSpring = false;
}
}
JavaScript => GetComponentInParent(): T;
C# => T GetComponentInParent();
Description 描述
Finds component in the parent.
从父对象查找组件。
Recurses upwards till it finds a valid component. Returns null if no component found.
向上递归直到找到一个有效的组件,否则返回空。