private static bool ReturnMaterial(Material mat, string path) { XEquipUtil.ReturnMaterial(mat); return(true); }
/// <summary> /// 处理mesh和tex的对应关系,并处理uv /// </summary> private bool Combine() { int partCount = 0; for (int i = (int)EPartType.ECombinePartStart; i < (int)EPartType.ECombinePartEnd; ++i) { PartLoadTask part = parts[i] as PartLoadTask; if (part.HasMesh()) { partCount++; } } CombineInstance[] combineArray = GetMatCombineInstanceArray(partCount); if (combineArray != null) { //1.mesh collection int index = 0; for (int i = (int)EPartType.ECombinePartStart; i < (int)EPartType.ECombinePartEnd; ++i) { PartLoadTask part = parts[i] as PartLoadTask; if (part.HasMesh()) { CombineInstance ci = new CombineInstance(); if (part.mesh != null) { ci.mesh = part.mesh; } ci.subMeshIndex = 0; combineArray[index++] = ci; } } //2.combine if (skin.sharedMesh == null) { skin.sharedMesh = new Mesh(); } else { skin.sharedMesh.Clear(true); } skin.gameObject.SetActive(false); skin.sharedMesh.CombineMeshes(combineArray, true, false); skin.gameObject.SetActive(true); //3.set material if (skin != null) { XEquipUtil.ReturnMaterial(skin.sharedMaterial); } skin.sharedMaterial = XEquipUtil.GetRoleMat(); skin.GetPropertyBlock(mpb); //4. postload - set texture for (EPartType part = EPartType.ECombinePartStart; part < EPartType.EMountEnd; ++part) { parts[(int)part].PostLoad(); } return(true); } return(false); }