//method to set the texture visually on each element
    private void SetTexture(AppearancePartType type, int textureIndex)
    {
        selectedParts[type] = textureIndex;

        var texture = GetSelectedTextureByType(type);

        Material[] mats = characterRenderer.materials;
        mats[(int)type].mainTexture = texture;
        characterRenderer.materials = mats;
    }
    //method to cycle through player appearence parts on button event
    public void SelectNextAppearancePart(int partIndex)
    {
        AppearancePartType partType = (AppearancePartType)partIndex;
        int max   = partsTextures[partType].Count - 1;
        int index = selectedParts[partType] + 1;

        if (index > max)
        {
            index = 0;
        }
        //call set texture by type
        SetTexture(partType, index);
    }
    //method to cycle through player appearence parts on button event
    public void SelectPreviousAppearancePart(int partIndex)
    {
        AppearancePartType partType = (AppearancePartType)partIndex;

        int max   = partsTextures[partType].Count;
        int index = selectedParts[partType] - 1;

        if (index < 0)
        {
            index = max - 1;
        }
        //call set texture by type
        SetTexture(partType, index);
    }
Exemplo n.º 4
0
 //method to return the appearence part by type
 public PlayerAppearancePart GetPart(AppearancePartType type)
 {
     return(parts.Single(part => part.partType == type));
 }
Exemplo n.º 5
0
        //method to set apperence part
        public void SetPartTexture(AppearancePartType type, string name)
        {
            PlayerAppearancePart part = GetPart(type);

            part.textureName = name;
        }
    //method to return the selected texture by type
    private Texture2D GetSelectedTextureByType(AppearancePartType type)
    {
        int selectedIndex = selectedParts[type];

        return(partsTextures[type][selectedIndex]);
    }