예제 #1
0
    public SlotDataAsset CreatSlot()
    {
        string     fold = string.Format("{0}/{1}/{2}", baseFold, PartName, UMAUtils.Slot);
        GameObject go   = gameObject.FindInChildren(gameObject.name + "_" + PartName);


        SkinnedMeshRenderer slotMesh = go.GetComponentInChildren <SkinnedMeshRenderer>();

        if (slotMesh == null)
        {
            throw new System.Exception(gameObject.name + " SkinnedMeshRenderer is null");
        }
        slotMesh.sharedMaterial  = null;
        slotMesh.sharedMaterials = new Material[0];

        SlotEditor    se   = new SlotEditor(slotMesh, go.name, fold, uMaterial);
        SlotDataAsset slot = se.Creat();

        return(slot);
    }
예제 #2
0
    public List <SlotOverlayItem> CreatData()
    {
        List <SlotOverlayItem> sos = new List <SlotOverlayItem>();
        int    submeshIndex        = 0;
        bool   first         = false;
        string firstSlotPath = null;

        for (int i = 0; i < sharedMaterials.Count; i++)
        {
            SlotOverlayItem item         = new SlotOverlayItem();
            string          materialName = sharedMaterials[i];
            string          name         = baseName + "-" + i;
            if (!first)
            {
                #region slot
                SlotEditor    so        = new SlotEditor(slotMesh, name, slotFold, Mat);
                SlotDataAsset firstSlot = so.Creat();
                item.slot     = firstSlot;
                firstSlotPath = string.Format("{0}/{1}_{2}.asset", PathHelper.GetRelativeAssetPath(slotFold), name, UMAUtils.Slot);
                #endregion

                first = true;
            }
            else
            {
                #region slot
                string target = string.Format("{0}/{1}_{2}.asset", PathHelper.GetRelativeAssetPath(slotFold), name, UMAUtils.Slot);
                FileUtil.CopyFileOrDirectory(firstSlotPath, target);

                AssetDatabase.Refresh();

                ObjectBase    obj     = new ObjectBase(target);
                SlotDataAsset slotSub = obj.Load <SlotDataAsset>();
                slotSub.subMeshIndex = i;
                item.slot            = slotSub;
                #endregion
            }

            #region overlay
            OverlayEditor oe = null;
            if (materialName.EndsWith(CharacterConst.Common))
            {
                oe = new OverlayEditor(overlayFold, comTexture, name, Mat);
            }
            else
            {
                oe = new OverlayEditor(overlayFold, diff, name, Mat);
            }

            OverlayDataAsset overlay = oe.CreatOverlay();
            item.overlay = overlay;
            #endregion

            #region index
            item.partIndex = wearpos * 10 + i;
            #endregion

            sos.Add(item);
        }


        return(sos);
    }