Ejemplo n.º 1
0
        // Update is called once per frame
        void Update()
        {
            if (DCA == null)
            {
                return;
            }
            bool  done    = false;
            float FadeVal = Time.deltaTime / time;

            if (Fade == FadeType.FadeIn)
            {
                Color.channelMask[0].a += FadeVal;
                if (Color.channelMask[0].a >= 1.0f)
                {
                    done = true;
                }
                DCA.SetColor(ColorName, Color, true);
            }
            else
            {
                Color.channelMask[0].a -= FadeVal;
                if (Color.channelMask[0].a <= 0.0f)
                {
                    done = true;
                }
                DCA.SetColor(ColorName, Color, true);
            }
            if (done)
            {
                Destroy(this);
            }
        }
Ejemplo n.º 2
0
    public void ChangeHairColor(Color col)
    {
#if _UMA
        dca.SetColor("Hair", col);
        dca.UpdateColors(true);
#endif
    }
Ejemplo n.º 3
0
        // the following methods recieve the raw dna value from the DynamicDNAConverterBehaviour (i.e. unchanged dna has a value of 0.5, with a maximum of 1 and a minimum of 0)
        public void ChangeCharacterRedness(string affectedDNA, float currentDNAVal)
        {
            var currenSkinColor = targetAvatar.GetColor("Skin");
            var newRed          = Mathf.Clamp((float)(((currentDNAVal - 0.5) * 2) + startingSkinColor.r), 0, 1);
            var newSkinColor    = new Color(newRed, currenSkinColor.color.g, currenSkinColor.color.b);

            targetAvatar.SetColor("Skin", newSkinColor, currenSkinColor.channelAdditiveMask[2], currenSkinColor.channelAdditiveMask[2].a, true);
        }
Ejemplo n.º 4
0
    public IEnumerator CustomizeCharacterAppearance(CharacterDataHolder characterData, DynamicCharacterAvatar newAvatar)
    {
        // Hide avatar until delay ends.
        newAvatar.gameObject.SetActive(false);

        // Unfortunately UMA needs a small delay to initialize.
        yield return(new WaitForSeconds(0.25f));

        // Delay ended. Show avatar.
        newAvatar.gameObject.SetActive(true);

        // Customize character.
        int hairType = characterData.GetHairType();

        if (characterData.GetRace() == 0)
        {
            newAvatar.ChangeRace("HumanMaleDCS");
            if (hairType != 0)
            {
                newAvatar.SetSlot("Hair", _hairModelsMale[characterData.GetHairType()]);
            }
        }
        if (characterData.GetRace() == 1)
        {
            newAvatar.ChangeRace("HumanFemaleDCS");
            if (hairType != 0)
            {
                newAvatar.SetSlot("Hair", _hairModelsFemale[characterData.GetHairType()]);
            }
        }

        // Set colors.
        newAvatar.SetColor("Hair", Util.IntToColor(characterData.GetHairColor()));
        newAvatar.SetColor("Skin", Util.IntToColor(characterData.GetSkinColor()));
        newAvatar.SetColor("Eyes", Util.IntToColor(characterData.GetEyeColor()));
        newAvatar.UpdateColors(true);

        Dictionary <string, DnaSetter> dna = newAvatar.GetDNA();

        dna["height"].Set(characterData.GetHeight());
        dna["belly"].Set(characterData.GetBelly());
        newAvatar.BuildCharacter(false);

        // Set visible equipable armor items.
        EquipItem(newAvatar, characterData.GetHeadItem());
        EquipItem(newAvatar, characterData.GetChestItem());
        EquipItem(newAvatar, characterData.GetLegsItem());
        EquipItem(newAvatar, characterData.GetHandsItem());
        EquipItem(newAvatar, characterData.GetFeetItem());

        // Without this delay, sometimes, we cannot not see mounted weapons.
        yield return(new WaitForSeconds(0.25f));

        // Set visible equipable left and right hand items.
        EquipItem(newAvatar, characterData.GetLeftHandItem());
        EquipItem(newAvatar, characterData.GetRightHandItem());
    }
Ejemplo n.º 5
0
        public void SetColor(string colorName, float fColor)
        {
            int Col = (int)fColor;

            if (sharedColorTables.FindIndex(s => s.name == colorName) > -1)
            {
                Avatar.SetColor(colorName, sharedColorTables[sharedColorTables.FindIndex(s => s.name == colorName)].sharedColorTable.colors[Col]);
            }
            else
            {
                Avatar.SetColor(colorName, GenericColorList.colors[Col]);
            }
        }
    public void ChangeColor(string name, float r, float g, float b)
    {
        Color currentColor = new Color(r, g, b, 1f);

        avatar.SetColor(name, currentColor);
        avatar.UpdateColors(true);
    }
        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 override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            string sharedColorName = "";

            avatar = playerData as DynamicCharacterAvatar;

            if (avatar == null)
            {
                if (Debug.isDebugBuild)
                {
                    Debug.LogWarning("No DynamicCharacterAvatar set for UmaColor Playable!");
                }
                return;
            }

            int  inputCount   = playable.GetInputCount();
            bool colorUpdated = false;

            if (inputCount <= 0)
            {
                return;
            }

            UmaColorBehaviour firstBehaviour = ((ScriptPlayable <UmaColorBehaviour>)playable.GetInput(0)).GetBehaviour();
            Color             finalColor     = Color.black;

            if (avatar.GetColor(firstBehaviour.sharedColorName) != null)
            {
                finalColor = avatar.GetColor(firstBehaviour.sharedColorName).color;
            }

            elapsedTime += info.deltaTime;

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

                sharedColorName = input.sharedColorName;
                finalColor      = (finalColor * (1f - inputWeight)) + (input.color * inputWeight);
            }

            if (elapsedTime >= timeStep)
            {
                elapsedTime = 0f;
                avatar.SetColor(sharedColorName, finalColor);
                colorUpdated = true;
            }

            if (colorUpdated)
            {
                avatar.UpdateColors(true);
            }
        }
Ejemplo n.º 9
0
    public void RPC_ChangeColor(string name, float r, float g, float b)
    {
        Color color = new Color(r, g, b, 1);

        t.colors[0].color = color;
        dca.SetColor(name, t.colors[0]);
        if (qnet.pv.IsMine)
        {
            preview.color = color;
        }
    }
Ejemplo n.º 10
0
 public void OnClick()
 {
     if (IsRemover)
     {
         Avatar.ClearColor(ColorName);
     }
     else
     {
         Avatar.SetColor(ColorName, ColorValue);
     }
 }
Ejemplo n.º 11
0
        public void Randomize(DynamicCharacterAvatar Avatar)
        {
            // Must clear that out!
            Avatar.WardrobeRecipes.Clear();

            UMARandomizer Randomizer = null;

            if (Randomizers != null)
            {
                if (Randomizers.Count == 0)
                {
                    return;
                }

                if (Randomizers.Count == 1)
                {
                    Randomizer = Randomizers[0];
                }
                else
                {
                    Randomizer = Randomizers[UnityEngine.Random.Range(0, Randomizers.Count)];
                }
            }
            if (Avatar != null && Randomizer != null)
            {
                RandomAvatar ra = Randomizer.GetRandomAvatar();
                Avatar.ChangeRaceData(ra.RaceName);
                //Avatar.BuildCharacterEnabled = true;
                var RandomDNA = ra.GetRandomDNA();
                Avatar.predefinedDNA = RandomDNA;
                var RandomSlots = ra.GetRandomSlots();

                if (ra.SharedColors != null && ra.SharedColors.Count > 0)
                {
                    foreach (RandomColors rc in ra.SharedColors)
                    {
                        if (rc.ColorTable != null)
                        {
                            Avatar.SetColor(rc.ColorName, GetRandomColor(rc), false);
                        }
                    }
                }
                foreach (string s in RandomSlots.Keys)
                {
                    List <RandomWardrobeSlot> RandomWardrobe = RandomSlots[s];
                    RandomWardrobeSlot        uwr            = GetRandomWardrobe(RandomWardrobe);
                    if (uwr.WardrobeSlot != null)
                    {
                        AddRandomSlot(Avatar, uwr);
                    }
                }
            }
        }
Ejemplo n.º 12
0
 // Start is called before the first frame update
 void Start()
 {
     DCA = GetComponent <DynamicCharacterAvatar>();
     if (DCA != null)
     {
         Color = DCA.GetColor(ColorName);
         if (Color == null)
         {
             Color = new OverlayColorData(3);
         }
         DCA.SetColor(ColorName, Color, false);
     }
 }
Ejemplo n.º 13
0
 private void AddRandomSlot(DynamicCharacterAvatar Avatar, RandomWardrobeSlot uwr)
 {
     Avatar.SetSlot(uwr.WardrobeSlot);
     if (uwr.Colors != null)
     {
         foreach (RandomColors rc in uwr.Colors)
         {
             if (rc.ColorTable != null)
             {
                 OverlayColorData ocd = GetRandomColor(rc);
                 Avatar.SetColor(rc.ColorName, ocd, false);
             }
         }
     }
 }
 public void OnClick()
 {
     Avatar.SetColor(ColorName, ColorValue);
     Avatar.UpdateColors(true);
 }
Ejemplo n.º 15
0
 /***************************************************************************
 *  Name: ChangeSkinColor
 *  Description: Changes the current skin color of the player.
 *  Input: Color representing the color to change to
 *  Output: None
 ***************************************************************************/
 public void ChangeSkinColor(Color color)
 {
     player.SetColor("Skin", color);
     //force a visual update of the character
     player.UpdateColors(true);
 }
Ejemplo n.º 16
0
 public void ChangeSkinColor(Color SkinColor)
 {
     characterAvatar.SetColor("Skin", SkinColor);
     characterAvatar.UpdateColors(true);
     Debug.Log(characterAvatar.GetColor("Skin").color);
 }
Ejemplo n.º 17
0
 public void ChangeSkinColor(Color color)
 {
     avatar.SetColor("Skin", color);
     avatar.UpdateColors(true);
     dataHolder.SetSkinColor(Util.ColorToInt(color));
 }
Ejemplo n.º 18
0
 void SetColor()
 {
     avatar.SetColor(sharedColorName, button.image.color);
     avatar.UpdateColors(true);
 }
Ejemplo n.º 19
0
 public void ChangeSkinColor(Color col)
 {
     avatar.SetColor("Skin", col);
     avatar.UpdateColors(true);
 }
Ejemplo n.º 20
0
 void ChangeSkinColor(int index)
 {
     avatar.SetColor("Skin", skinColors[index]);
     avatar.UpdateColors(true);
 }