コード例 #1
0
ファイル: MaterialEditor.cs プロジェクト: xfilson/dn_asset
 private static bool ReturnMaterial(Material mat, string path)
 {
     XEquipUtil.ReturnMaterial(mat);
     return(true);
 }
コード例 #2
0
    /// <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);
    }