示例#1
0
        public void CreateExpression(string name)
        {
            List <BlendValue> bodyVals    = new List <BlendValue>();
            List <BlendValue> eyelashVals = new List <BlendValue>();

            for (int i = 0; i < bodyBlendshapeCount; i++)
            {
                float w = body.GetBlendShapeWeight(i);
                if (w != 0f)
                {
                    bodyVals.Add(new BlendValue {
                        index = i, weight = w
                    });
                }
            }

            for (int i = 0; i < eyelashBlendshapeCount; i++)
            {
                float w = eyelash.GetBlendShapeWeight(i);
                if (w != 0f)
                {
                    eyelashVals.Add(new BlendValue {
                        index = i, weight = w
                    });
                }
            }

            BlendPackage package = new BlendPackage
            {
                bodyValues    = bodyVals.ToArray(),
                eyelashValues = eyelashVals.ToArray()
            };

            expressionMap[name] = package;
        }
示例#2
0
        public void MorphExpressionAndReturn(string name, float morphTime = 1f, float holdTime = 2f)
        {
            if (expressionMap.ContainsKey(name))
            {
                BlendPackage package = expressionMap[name];
                for (int i = 0; i < package.bodyValues.Length; i++)
                {
                    TweenAndReturnSkin(body, package.bodyValues[i].index, package.bodyValues[i].weight, morphTime, holdTime);
                }

                for (int i = 0; i < package.eyelashValues.Length; i++)
                {
                    TweenAndReturnSkin(eyelash, package.bodyValues[i].index, package.bodyValues[i].weight, morphTime, holdTime);
                }
            }
        }
示例#3
0
        public void SetExpressionImmediate(string name, bool resetShapes = true)
        {
            if (resetShapes)
            {
                ResetShapes();
            }

            if (expressionMap.ContainsKey(name))
            {
                BlendPackage package = expressionMap[name];
                for (int i = 0; i < package.bodyValues.Length; i++)
                {
                    body.SetBlendShapeWeight(package.bodyValues[i].index, package.bodyValues[i].weight);
                }

                for (int i = 0; i < package.eyelashValues.Length; i++)
                {
                    eyelash.SetBlendShapeWeight(package.bodyValues[i].index, package.bodyValues[i].weight);
                }
            }
        }