/// <summary>加载完成</summary> /// <param name="res"></param> private void OnLoader_Complete(NormalRes res) { TextureRes imgRes = res as TextureRes; SkinManagerLoaderItem loaderItem = m_currentLoaders[0]; Transform target = loaderItem.target; E_SkinPart part = loaderItem.part; //GoalKeeper keeper = target.GetComponent<GoalKeeper>(); //if(null != keeper && ) m_currentLoaders.RemoveAt(0); if (m_currentLoaders.Count > 0) { ResourceManager.Instance.LoadTexture(m_currentLoaders[0].skinId, OnLoader_Complete, OnLoader_Error); } else { if (null != LoaderCompleteCallBack) { LoaderCompleteCallBack(); } inLoading = false; Clear(); } if (null != target) { SkinnedMeshRenderer render = target.GetComponent <SkinnedMeshRenderer>(); Material mat = render.material; mat.mainTexture = imgRes.m_texture; render.material = mat; } res = 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; }