/// <summary>
    /// 根据类型移除图标
    /// </summary>
    /// <param name="characterStatus"></param>
    public void RemoveStatusIconByType(CharacterStatusIconEnum characterStatus)
    {
        for (int i = 0; i < listStatusIcon.Count; i++)
        {
            CharacterStatusIconItemCpt itemCpt = listStatusIcon[i];
            if (itemCpt.statusIconData.iconStatus == characterStatus)
            {
                if (itemCpt && itemCpt.gameObject)
                {
                    //itemCpt.transform.DOScale(new Vector3(0, 0, 0), 0.5f).OnComplete(delegate
                    //{
                    //    if (itemCpt && itemCpt.gameObject)
                    //        Destroy(itemCpt.gameObject);
                    //});
                    Destroy(itemCpt.gameObject);
                    listStatusIcon.Remove(itemCpt);
                    i--;
                }
            }
        }
        float totalX = (listStatusIcon.Count - 1) * 0.5f;
        float startX = -(totalX / 2f);

        //设置新的位置
        for (int i = 0; i < listStatusIcon.Count; i++)
        {
            CharacterStatusIconItemCpt itemCpt = listStatusIcon[i];
            if (itemCpt && itemCpt.gameObject)
            {
                itemCpt.transform.DOLocalMoveX(startX + i * 0.5f, 0.5f);
            }
        }
    }
Beispiel #2
0
 /// <summary>
 /// 通过类型删除图标
 /// </summary>
 /// <param name="type"></param>
 public void RemoveStatusIconByType(CharacterStatusIconEnum type)
 {
     try
     {
         characterStatusIcon.RemoveStatusIconByType(type);
     }
     catch
     {
     }
 }