Exemple #1
0
        public void Destroy()
        {
            Playable output = this.Output;
            Playable input0 = this.Input0;

            output.DisconnectInput(0);
            this.mixer.DisconnectInput(0);

            output.ConnectInput(0, input0, 0);

            switch (output.GetInputCount())
            {
            case 1:
                output.SetInputWeight(0, 1f);
                break;

            case 2:
                float outputWeight = this.mixer.GetInputWeight(0);
                output.SetInputWeight(0, outputWeight);
                break;
            }

            IEnumerator destroy = this.DestroyNextFrame();

            CoroutinesManager.Instance.StartCoroutine(destroy);
        }
    public override void OnPlayableCreate(Playable playable)
    {
        base.OnPlayableCreate(playable);

        m_playableGraph = playable.GetGraph();
        m_mixerPlayable = AnimationMixerPlayable.Create(m_playableGraph, 2);
        playable.ConnectInput(0, m_mixerPlayable, 0);
        playable.SetInputWeight(0, 0);
    }
Exemple #3
0
    public void Init()
    {
        clipPlayable1 = AnimationClipPlayable.Create(m_playableGraph, clip1);
        inPlayable.ConnectInput(0, clipPlayable1, 0);

        clipPlayable2 = AnimationClipPlayable.Create(m_playableGraph, clip2);
        //inPlayable.ConnectInput(1, clipPlayable2, 0);

        //inPlayable.SetInputWeight(0, 0);
        //inPlayable.SetInputWeight(1, 1);
    }
Exemple #4
0
            public CollectionNode(PlayableGraph graph, GameObject owner)
            {
                playableGraph = graph;
                ownerObject   = owner;
                childNodes    = new List <T>();

                passtroughPlayable = Playable.Create(graph, mixerOutputTypes.Length);
                passtroughPlayable.SetOutputCount(mixerOutputTypes.Length);
                passtroughPlayable.SetTraversalMode(PlayableTraversalMode.Passthrough);

                animationPlayable = CreateAnimationPlayable(graph, owner);
                passtroughPlayable.ConnectInput(0, animationPlayable, 0, 1f);

                ikPlayable = CreateIKPlayable(graph, owner);
                passtroughPlayable.ConnectInput(1, ikPlayable, 0, 1f);

                playables = new[]
                {
                    animationPlayable,
                    ikPlayable
                };
            }
Exemple #5
0
        override public void PrepareFrame(Playable playable, FrameData info)
        {
            if (mFinishFrameId == info.frameId)
            {
                var cb = mFinishCb;
                mFinishCb = null;
                cb.Invoke(0);
                return;
            }
            var count = mMixer.GetInputCount();

            if (count == 0)
            {
                return;
            }
            if (count > 1 && mTransitionTime >= 0f)
            {
                mTransitionTime -= info.deltaTime;
                if (mTransitionTime > 0f)
                {
                    var rate = mTransitionTime / mTransitionDuration;
                    for (var i = 0; i < count - 1; ++i)
                    {
                        mMixer.SetInputWeight(i, Mathf.Lerp(mMixer.GetInputWeight(i), 0f, rate));
                    }
                    mMixer.SetInputWeight(count - 1, Mathf.Lerp(mMixer.GetInputWeight(count - 1), 1f, 1f - rate));
                }
                else
                {
                    for (var i = 0; i < count - 1; ++i)
                    {
                        mMixer.GetInput(i).Destroy();
                    }
                    var clipPlayable = mMixer.GetInput(count - 1);
                    mMixer.DisconnectInput(count - 1);
                    mMixer.SetInputCount(1);
                    mMixer.ConnectInput(0, clipPlayable, 0);
                    mMixer.SetInputWeight(0, 1.0f);
                }
            }
            if (mActionTime > 0)
            {
                mActionTime -= info.deltaTime;
                if (mActionTime <= 0 && mFinishCb != null)
                {
                    mFinishFrameId = info.frameId + 2;
                }
            }
        }
Exemple #6
0
            protected virtual void UpdateGraph()
            {
                var animationInput = 0;
                var ikInput        = 0;

                DisconnectAllInputs(animationPlayable);
                DisconnectAllInputs(ikPlayable);

                foreach (var child in childNodes)
                {
                    child.connections.Clear();

                    var playable    = child.node.Playable;
                    var outputCount = child.node.OutputTypes.Length;
                    var outputTypes = child.node.OutputTypes;

                    for (var o = 0; o < outputCount; o++)
                    {
                        switch (outputTypes[o])
                        {
                        case StreamType.Animation:
                            PrepareInputForConnection(animationPlayable, animationInput);
                            animationPlayable.ConnectInput(animationInput, playable, o);
                            child.connections.Add(new KeyValuePair <int, int>((int)StreamType.Animation, animationInput));
                            animationInput++;
                            break;

                        case StreamType.IK:
                            PrepareInputForConnection(ikPlayable, ikInput);
                            ikPlayable.ConnectInput(ikInput, playable, o);
                            child.connections.Add(new KeyValuePair <int, int>((int)StreamType.IK, ikInput));
                            ikInput++;
                            break;

                        default:
                            Debug.LogError("Unknown output type encountered: " + outputTypes[o]);
                            break;
                        }
                    }

                    child.ApplyAllParams();
                }

                RemoveUnusedInputs(animationPlayable, animationInput);
                RemoveUnusedInputs(ikPlayable, ikInput);
            }
Exemple #7
0
        public void SetOutput(BaseNode node)
        {
            OutputNode = node;

            if (node.Playable.GetOutputCount() == 0)
            {
                node.Playable.SetOutputCount(1);
            }

            if (Playable.GetInputCount() > 0)
            {
                if (!Playable.GetInput(0).IsNull())
                {
                    Playable.DisconnectInput(0);
                }

                Playable.ConnectInput(0, node.Playable, 0, 1f);
            }
            else
            {
                Playable.AddInput(node.Playable, 0, 1f);
            }
        }