Exemplo n.º 1
0
    public void OnItemChange(NkSoldierInfo kSoldier, int itemindex, GameObject kGameObj)
    {
        if (kSoldier == null || null == kGameObj)
        {
            return;
        }
        eEQUIP_ITEM itempos = eEQUIP_ITEM.EQUIP_ITEM_MAX;

        if (itemindex == 3)
        {
            itempos = eEQUIP_ITEM.EQUIP_WEAPON1;
        }
        ITEM equipItem = kSoldier.GetEquipItem((int)itempos);

        if (equipItem != null)
        {
            int       rank          = equipItem.m_nOption[2];
            string    strName       = ItemManager.RankStateString(rank);
            Transform childContains = NkUtil.GetChildContains(kGameObj.transform, strName);
            if (null != childContains)
            {
                Transform transform = kGameObj.transform;
                childContains.parent = null;
                int childCount = transform.childCount;
                for (int i = 0; i < childCount; i++)
                {
                    Transform child = transform.GetChild(0);
                    UnityEngine.Object.DestroyImmediate(child.gameObject);
                }
                childContains.parent = transform;
            }
        }
    }
Exemplo n.º 2
0
 public static Transform GetChildContains(Transform kTrans, string strName)
 {
     if (kTrans.name.Contains(strName))
     {
         return(kTrans);
     }
     for (int i = 0; i < kTrans.childCount; i++)
     {
         Transform childContains = NkUtil.GetChildContains(kTrans.GetChild(i), strName);
         if (null != childContains)
         {
             return(childContains);
         }
     }
     return(null);
 }