umasteeringgroup / UMA

Unity Multipurpose Avatar
MIT License
737 stars 169 forks source link

After change the race DNA values doesn't change #257

Closed grillo78 closed 5 years ago

grillo78 commented 5 years ago

Describe the bug After change the race dna values doesn't change. Video showing the problem: https://youtu.be/2pM9Yg_TTDQ

Environment (please complete the following information):

My C# Script: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UMA; using UMA.CharacterSystem;

public class PlayerModelCreation : MonoBehaviour { public UMAData umaData; public DynamicUMADnaBase umaDna; public Slider headWidthSlider; public DynamicCharacterAvatar avatar; public bool isBoy = false;

// Use this for initialization
public void setUMAData()
{
    umaData = avatar.umaData;
    umaDna = (DynamicUMADnaBase)umaData.umaRecipe.dnaValues[0];
    headWidthSlider.SetValueWithoutNotify(umaDna.GetValue(2));
}

public void setHeadWidth(float value)
{
    umaDna.SetValue("headWidth", value);
    umaData.Dirty(true, false, false);
}

public void changeGender()
{
    if (isBoy)
    {
        isBoy = false;
        avatar.ChangeRace("HumanFemaleHighPoly");
    }
    else
    {
        isBoy = true;
        avatar.ChangeRace("HumanMaleHighPoly");
    }
}

}

Jaimi commented 5 years ago

Your umadata and DNA is stale, you have to get it again after changing your race. or you can use the DNASetters, but you have to get them again also.

grillo78 commented 5 years ago

I change the script to this: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UMA; using UMA.CharacterSystem;

public class PlayerModelCreation : MonoBehaviour { public UMAData umaData; public DynamicUMADnaBase umaDna; public Slider headWidthSlider; public DynamicCharacterAvatar avatar; public bool isBoy = false;

// Use this for initialization
public void setUMAData()
{
    umaData = avatar.umaData;
    umaDna = (DynamicUMADnaBase)umaData.umaRecipe.dnaValues[0];
    headWidthSlider.SetValueWithoutNotify(umaDna.GetValue(2));
}

public void setHeadWidth(float value)
{
    umaDna.SetValue("headWidth", value);
    umaData.Dirty(true, false, false);
}

public void changeGender()
{
    if (isBoy)
    {
        isBoy = false;
        avatar.ChangeRace("HumanFemaleHighPoly");
        umaData = avatar.umaData;
        umaDna = (DynamicUMADnaBase)umaData.umaRecipe.dnaValues[0];
    }
    else
    {
        isBoy = true;
        avatar.ChangeRace("HumanMaleHighPoly");
        umaData = avatar.umaData;
        umaDna = (DynamicUMADnaBase)umaData.umaRecipe.dnaValues[0];
    }
}

} but the problem persist, I got this error imagen

Jaimi commented 5 years ago

That doesn't do anything, because it hasn't been rebuilt yet. You need to wait for it to rebuild, and then do it. There are several events on the DCA that will help. You should look at CharacterDNAUpdated or CharacterCreated.

grillo78 commented 5 years ago

fixed, thx u

Jaimi commented 5 years ago

You're welcome