/// <summary>
    /// Set character clothes
    /// </summary>
    /// <param name="type">Type of clothes</param>
    /// <param name="index">Index of element</param>
    public void SetElementByIndex(ClothesPartType type, int index)
    {
        ClothesAnchor ca = GetClothesAnchor(type);

        ClothPreset clothPreset = getPreset(type, clothesActiveIndexes[type]);


        if (clothPreset != null)
        {
            UnHideParts(clothPreset.hideParts, type);
        }

        if (index != -1)
        {
            var newPreset = getPreset(type, index);

            for (var i = 0; i < ca.skinnedMesh.Length; i++)
            {
                ca.skinnedMesh[i].sharedMesh = newPreset.mesh[i];
            }

            HideParts(newPreset.hideParts);
        }
        else
        {
            foreach (var sm in ca.skinnedMesh)
            {
                sm.sharedMesh = null;
            }
        }

        clothesActiveIndexes[type] = index;
    }
    /// <summary>
    /// Set character clothes
    /// </summary>
    /// <param name="type">Type of clothes</param>
    /// <param name="index">Index of element</param>
    public void SetElementByIndex(ClothesPartType type, int index)
    {
        ClothesAnchor ca = GetClothesAnchor(type);

        ClothPreset clothPreset = getPreset(type, clothesActiveIndexes[type]);


        if (clothPreset != null)
        {
            UnHideParts(clothPreset.hideParts, type);
        }

        if (index != -1)
        {
            var newPreset = getPreset(type, index);
            ca.skinnedMesh.sharedMesh = newPreset.mesh;

            HideParts(newPreset.hideParts);
        }
        else
        {
            ca.skinnedMesh.sharedMesh = null;
        }

        clothesActiveIndexes[type] = index;
    }
    /// <summary>
    /// Set character clothes
    /// </summary>
    /// <param name="type">Type of clothes</param>
    /// <param name="index">Index of element</param>
    public void SetElementByIndex(ClothesPartType type, int index)
    {
        ClothesAnchor ca          = GetClothesAnchor(type);
        ClothPreset   clothPreset = getPreset(type, clothesActiveIndexes[type]);
        float         yOffset     = 0f;

        if (clothPreset != null)
        {
            UnHideParts(clothPreset.hideParts, type);
        }

        if (type == ClothesPartType.Pants || type == ClothesPartType.TShirt)
        {
            UnHideParts(new string[] { "Spine" }, type);
        }

        clothesActiveIndexes[type] = index;

        if (index != -1)
        {
            var newPreset = getPreset(type, index);

            yOffset = newPreset.yOffset;

            for (var i = 0; i < ca.skinnedMesh.Length; i++)
            {
                ca.skinnedMesh[i].sharedMesh = newPreset.mesh[i];

                for (var blendCount = 0; blendCount < ca.skinnedMesh[i].sharedMesh.blendShapeCount; blendCount++)
                {
                    ca.skinnedMesh[i].SetBlendShapeWeight(blendCount, bodyShapeWeight[blendCount]);
                }
            }
            ClothPreset shirt = getPreset(ClothesPartType.TShirt, clothesActiveIndexes[ClothesPartType.TShirt]);
            ClothPreset pants = getPreset(ClothesPartType.Pants, clothesActiveIndexes[ClothesPartType.Pants]);
            if ((shirt != null && pants != null) && (shirt.notVisibleSpine && pants.notVisibleSpine))
            {
                HideParts(new string[] { "Spine" });
            }
            HideParts(newPreset.hideParts);
        }
        else
        {
            foreach (var sm in ca.skinnedMesh)
            {
                sm.sharedMesh = null;
            }
        }
        if (transforms[0].localPosition.y != yOffset && type == ClothesPartType.Shoes)
        {
            foreach (var tr in transforms)
            {
                tr.localPosition = new Vector3(tr.localPosition.x, yOffset, tr.localPosition.z);
            }
        }
    }
Example #4
0
        public ClothPreset GetClothPreset()
        {
            var preset = new ClothPreset();

            preset.mesh      = mesh;
            preset.hideParts = hideParts;
            preset.yOffset   = yOffset;
            preset.mats      = mats;

            return(preset);
        }