/// <summary> /// 获取皮肤项 /// </summary> /// <param name="target"></param> /// <returns></returns> public SkinManagerItem GetItem(Transform target) { if (null == m_dic) { m_dic = new Dictionary <Transform, SkinManagerItem>(); } SkinManagerItem item; try { if (!m_dic.TryGetValue(target, out item)) { item = new SkinManagerItem(); item.owner = target; item.skin = DisplayUtil.SearchHierarchyForBone(target.transform, SkinName_Skin); item.hair = DisplayUtil.SearchHierarchyForBone(target.transform, SkinName_Hair); item.cloth = DisplayUtil.SearchHierarchyForBone(target.transform, SkinName_Cloth); m_dic[target] = item; } return(item); } catch { Debug.Log("is destory : " + target); } target = null; return(null); }
/// <summary>设置皮肤</summary> public void SetSkin(Transform target, string skinId, E_SkinPart part) { if (null == m_currentLoaders) { m_currentLoaders = new List <SkinManagerLoaderItem>(); } SkinManagerItem skinItem = GetItem(target); SkinManagerLoaderItem item = new SkinManagerLoaderItem(); item.skinId = "playerskin/" + skinId + ".png"; item.part = part; item.ownerName = target.name; item.owner = target; m_currentLoaders.Add(item); switch (part) { case E_SkinPart.Cloth: item.target = skinItem.cloth; break; case E_SkinPart.Hair: item.target = skinItem.hair; break; case E_SkinPart.Skin: item.target = skinItem.skin; break; } if (!inLoading) { ResourceManager.Instance.LoadTexture(item.skinId, OnLoader_Complete, OnLoader_Error); } inLoading = true; target = null; skinId = null; }