當前位置: 首頁>>代碼示例>>C#>>正文


C# Component.GetComponentInChildren方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:HiroLord,項目名稱:VGDesign,代碼行數:10,代碼來源:WeaponPickup.cs

示例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 ();
 }
開發者ID:HiroLord,項目名稱:VGDesign,代碼行數:11,代碼來源:PlayerItemPickup.cs

示例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 ();
 }
開發者ID:HiroLord,項目名稱:VGDesign,代碼行數:11,代碼來源:WeaponItemPickup.cs

示例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);
     }
 }
開發者ID:HiroLord,項目名稱:VGDesign,代碼行數:13,代碼來源:WeaponAmmoPickup.cs

示例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);
 }
開發者ID:paulmoore,項目名稱:UnJect,代碼行數:30,代碼來源:Attributes.cs


注:本文中的UnityEngine.Component.GetComponentInChildren方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。