本文整理汇总了C#中UnityEngine.Component.GetComponentInChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Component.GetComponentInChildren方法的具体用法?C# Component.GetComponentInChildren怎么用?C# Component.GetComponentInChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Component
的用法示例。
在下文中一共展示了Component.GetComponentInChildren方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter
void OnTriggerEnter(Component other)
{
Shooting s = other.GetComponentInChildren<Shooting>();
if (s != null) {
string name = this.gameObject.name;
name = name.Substring(0,name.IndexOf("Pickup"));
s.changeWeapon (WeaponLibrary.weapons [name]);
print (s.weapon.name);
}
}
示例2: OnTriggerEnter
public override void OnTriggerEnter(Component other)
{
try{
player = other.GetComponentInChildren<Player>();
}catch(UnityException e){
}
string name = this.gameObject.name;
name = name.Substring(0,name.IndexOf("Item"));
player.addPlayerItem (ItemLibrary.playerItems [name]);
destroyObject ();
}
示例3: OnTriggerEnter
public override void OnTriggerEnter(Component other)
{
try{
shooting = other.GetComponentInChildren<Shooting>();
} catch(UnityException e){
}
string name = this.gameObject.name;
name = name.Substring(0,name.IndexOf("Item"));
shooting.addWeaponItem (ItemLibrary.weaponItems [name]);
destroyObject ();
}
示例4: OnTriggerEnter
public override void OnTriggerEnter(Component other)
{
Shooting s = other.GetComponentInChildren<Shooting> ();
bool full = true;
if (s != null) {
full = s.addClip();
}
if (full) {
src.Play ();
//gameObject.renderer.enabled = false;
Destroy(gameObject, src.clip.length);
}
}
示例5: FindDependency
public override object FindDependency(Component comp, FieldInfo field)
{
if (SearchParents) {
comp = comp.transform.root;
}
if (IsContainerType(field)) {
Type type;
if (field.FieldType.IsArray) {
type = field.FieldType.GetElementType();
} else if (typeof(IList).IsAssignableFrom(field.FieldType)) {
if (field.FieldType.GetGenericArguments().Length >= 1) {
type = field.FieldType.GetGenericArguments()[0];
} else {
Debug.LogError(string.Format("{0} expected at least one generic argument from the type {1}, use List<T>", this, field.FieldType));
return null;
}
} else {
Debug.LogError("Shouldn't be here");
type = null;
}
if (Recursive) {
return CreateArrayOrList(field, ConvertToGOArray(comp.GetComponentsInChildren(type, IncludeInactive)));
}
return CreateArrayOrList(field, ConvertToGOArray(comp.GetComponents(type)));
}
if (Recursive) {
return comp.GetComponentInChildren(field.FieldType);
}
return comp.GetComponent(field.FieldType);
}