Пример #1
0
        /// <summary>
        /// Set the morph's weight and reduce the weights of all other morphs automatically
        /// </summary>
        /// <param name="index">The index of the morph</param>
        /// <param name="percent">percent (0-1) to set the morph's weight to</param>
        public void SetMorphState(int index, float percent)
        {
            if (!hasMorph)
            {
                return;
            }
            percent = Mathf.Clamp01(percent);
            float inversePercent = 1f - percent;

            for (int i = 0; i < _morph.GetChannelCount(); i++)
            {
                if (i != index)
                {
                    float weight = _morph.GetWeight(i);
                    weight = Mathf.Clamp(weight, 0f, inversePercent);
                    _morph.SetWeight(i, weight);
                }
                else
                {
                    _morph.SetWeight(i, percent);
                }
            }
        }