public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
            {
                ScriptPlayable <SkinnedMeshBlendshapePlayableBehaviour> playable = ScriptPlayable <SkinnedMeshBlendshapePlayableBehaviour> .Create(graph, _data);

                SkinnedMeshBlendshapePlayableBehaviour clone = playable.GetBehaviour();

                clone._clip = this;
                return(playable);
            }
Пример #2
0
            public override void ProcessFrame(Playable playable, FrameData info, object playerData)
            {
                SkinnedMeshBlendshapeTrack track = (SkinnedMeshBlendshapeTrack)_trackAsset;

                if (!_parentBinding)
                {
                    _trackBinding = playerData as SkinnedMeshRenderer;
                }

                if (_trackBinding == null || track._blendShapeIndex >= _trackBinding.sharedMesh.blendShapeCount)
                {
                    return;
                }

                if (_firstFrame)
                {
                    _defaultValue = _trackBinding.GetBlendShapeWeight(track._blendShapeIndex);
                    _firstFrame   = false;
                }

                float weight = _defaultValue;

                int numInputs = playable.GetInputCount();

                for (int i = 0; i < numInputs; i++)
                {
                    float inputWeight = playable.GetInputWeight(i);

                    if (inputWeight > 0.0f)
                    {
                        ScriptPlayable <SkinnedMeshBlendshapePlayableBehaviour> scriptPlayable = (ScriptPlayable <SkinnedMeshBlendshapePlayableBehaviour>)playable.GetInput(i);
                        SkinnedMeshBlendshapePlayableBehaviour inputBehaviour = scriptPlayable.GetBehaviour();

                        weight = Mathf.Lerp(weight, inputBehaviour._weight, inputWeight);
                    }
                }

                _trackBinding.SetBlendShapeWeight(track._blendShapeIndex, weight);
            }