Example #1
0
 public void ValueChanged(string name, float value)
 {
     dna[name].Set(value);                      //sets dna value defined by name and value input.
     avatar.ForceUpdate(true, false, false);    //updates the avatar with the dna change.
     dna          = avatar.GetDNA();            //Refresh's dictionary with the new dna settings.
     slider.value = dna[gameObject.name].Value; //sets slider to the new values
 }
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            DynamicCharacterAvatar avatar = playerData as DynamicCharacterAvatar;

            if (avatar == null || !Application.isPlaying)
            {
                return;
            }

            Dictionary <string, DnaSetter> allDNA = avatar.GetDNA();

            int inputCount = playable.GetInputCount();

            for (int i = 0; i < inputCount; i++)
            {
                float inputWeight = playable.GetInputWeight(i);
                ScriptPlayable <UmaDnaBehaviour> inputPlayable = (ScriptPlayable <UmaDnaBehaviour>)playable.GetInput(i);
                UmaDnaBehaviour input = inputPlayable.GetBehaviour();

                foreach (UmaDnaBehaviour.DnaTuple dna in input.dnaValues)
                {
                    if (allDNA.ContainsKey(dna.Name))
                    {
                        float currentValue = allDNA[dna.Name].Value * (1f - inputWeight);
                        allDNA[dna.Name].Set(currentValue + (dna.Value * inputWeight));
                    }
                }

                if (input.rebuildImmediately)
                {
                    avatar.ForceUpdate(true, false, false);
                }
            }
        }
Example #3
0
        public void ChangeValue(float value)
        {
            if (_dnr == null)             //No specified DNA Range Asset for this DNA
            {
                _Owner.SetValue(_Index, value);
                _Avatar.ForceUpdate(true, false, false);
                return;
            }

            if (_dnr.ValueInRange(_Index, value))
            {
                _Owner.SetValue(_Index, value);
                _Avatar.ForceUpdate(true, false, false);
                return;
            }
            else
            {
                //Debug.LogWarning ("DNA Value out of range!");
            }
        }
 public void OnClick()
 {
     // If there is no recipe, then just remove whatever is there (if any)
     if (Recipe == null)
     {
         Avatar.ClearSlot(Slot);
         Avatar.BuildCharacter(true);
         Avatar.ForceUpdate(true, true, true);
         return;
     }
     // We have a recipe.
     // The wardrobe slot is defined in the recipe itself, so setting a recipe is all
     // that is needed to "put on" a wardrobe item.
     // Any recipe that already exists at that slot will be removed - so, for example,
     // putting on a shirt will replace the existing shirt if one exists.
     Avatar.SetSlot(Recipe);
     // Rebuild the character so its wearing the new wardrobe item.
     Avatar.BuildCharacter(true);
     Avatar.ForceUpdate(true, true, true);
 }
Example #5
0
 private void UpdateDNA()
 {
     if (!qnet.pv.IsMine)
     {
         return;
     }
     foreach (Transform child in bodyFaceList)
     {
         Destroy(child.gameObject);
     }
     foreach (var x in dca.GetDNA().ToList().OrderBy(v => v.Key))
     {
         if (!x.Key.ToLower().Contains("skin"))
         {
             GameObject o = Instantiate(prefab, bodyFaceList);
             o.GetComponentInChildren <Text>().text = x.Key.BreakupCamelCase();
             Slider slider = o.GetComponentInChildren <Slider>();
             slider.onValueChanged.AddListener(delegate { ChangeValue(x.Key, slider.value); });
             ChangeValue(x.Key, slider.value = 0.5f);
             dca.ForceUpdate(true, false, false);
         }
     }
 }
Example #6
0
 public void ValueChanged(float val)
 {
     if (DNA != null)
     {
         DNA.Set(val);
         avatar.ForceUpdate(true, false, false);
     }
     else
     {
         if (Debug.isDebugBuild)
         {
             Debug.Log("DNA is null!");
         }
     }
 }
        private void RandomizeAvatar(DynamicCharacterAvatar Avatar)
        {
            Dictionary <string, List <UMATextRecipe> > recipes = Avatar.AvailableRecipes;

            // Set random wardrobe slots.
            foreach (string SlotName in recipes.Keys)
            {
                int cnt = recipes[SlotName].Count;
                if (cnt > 0)
                {
                    //Get a random recipe from the slot, and apply it
                    int min = -1;
                    if (SlotName == "Legs")
                    {
                        min = 0;                     // Don't allow pants removal in random test
                    }
                    int rnd = Random.Range(min, cnt);
                    if (rnd == -1)
                    {
                        Avatar.ClearSlot(SlotName);
                    }
                    else
                    {
                        Avatar.SetSlot(recipes[SlotName][rnd]);
                    }
                }
            }

            // Set Random DNA
            Dictionary <string, DnaSetter> setters = Avatar.GetDNA();

            foreach (KeyValuePair <string, DnaSetter> dna in setters)
            {
                dna.Value.Set(0.35f + (Random.value * 0.3f));
            }

            // Set Random Colors for Skin and Hair
            int RandHair = Random.Range(0, HairColors.colors.Length);
            int RandSkin = Random.Range(0, SkinColors.colors.Length);

            Avatar.SetColor("Hair", HairColors.colors[RandHair]);
            Avatar.SetColor("Skin", SkinColors.colors[RandSkin]);
            Avatar.BuildCharacter(true);
            Avatar.ForceUpdate(true, true, true);
        }
    public void SetDNA(float Value)
    {
        if (Avatar == null)
        {
            Avatar = FindAvatar();
        }
        if (Avatar == null)
        {
            return;
        }

        // Set the DNA on the Avatar.
        // Case must match.
        // If you cache DNA, you must do it after the character is completely built
        var MyDNA = Avatar.GetDNA();

        if (MyDNA.ContainsKey(DnaName))
        {
            MyDNA[DnaName].Set(Value);
            Avatar.ForceUpdate(true);
        }
    }
Example #9
0
 public void ChangeValue(float value)
 {
     _Owner.SetValue(_Index, value);
     _Avatar.ForceUpdate(true, false, false);
 }
    public void EyebrowChange()
    {
        // Get the available UMATextRecipes for this slot.
        List <UMATextRecipe> slotRecipes = avatar.AvailableRecipes["Eyebrows"];

        /*foreach (UMATextRecipe utr in slotRecipes)
         * {
         *  Debug.Log(utr.name);
         * }*/

        if (drp.value == 0)
        {
            avatar.ClearSlot("Eyebrows");
            avatar.BuildCharacter();
            avatar.ForceUpdate(true, true, true);
        }

        if (drp.value == 1)
        {
            foreach (UMATextRecipe utr in slotRecipes)
            {
                if (utr.name == "MaleBrow01")
                {
                    avatar.SetSlot(utr);
                    avatar.BuildCharacter();
                    avatar.ForceUpdate(true, true, true);
                    Debug.Log(utr.name);
                }
            }
        }

        if (drp.value == 2)
        {
            foreach (UMATextRecipe utr in slotRecipes)
            {
                if (utr.name == "MaleBrow02")
                {
                    avatar.SetSlot(utr);
                    avatar.BuildCharacter();
                    avatar.ForceUpdate(true, true, true);
                    Debug.Log(utr.name);
                }
            }
        }

        if (drp.value == 3)
        {
            foreach (UMATextRecipe utr in slotRecipes)
            {
                if (utr.name == "MaleBrowHR")
                {
                    avatar.SetSlot(utr);
                    avatar.BuildCharacter();
                    avatar.ForceUpdate(true, true, true);
                    Debug.Log(utr.name);
                }
            }
        }
    }
 public void ValueChanged(float value)
 {
     DNA.Set(value);
     Avatar.ForceUpdate(true);
 }