예제 #1
0
 public void Init()
 {
     if (handData)
     {
         graph   = PlayableGraph.Create("Hand Animation Controller graph");
         fingers = new Finger[5];
         var fingerMixer = AnimationLayerMixerPlayable.Create(graph, fingers.Length);
         for (uint i = 0; i < fingers.Length; i++)
         {
             fingers[i] = new Finger(graph, handData.closed, handData.opened, handData[(int)i]);
             fingerMixer.SetLayerAdditive(i, false);
             fingerMixer.SetLayerMaskFromAvatarMask(i, handData[(int)i]);
             graph.Connect(fingers[i].Mixer, 0, fingerMixer, (int)i);
             fingerMixer.SetInputWeight((int)i, 1);
         }
         handMixer = AnimationMixerPlayable.Create(graph, 2);
         graph.Connect(fingerMixer, 0, handMixer, 0);
         handMixer.SetInputWeight(0, 1);
         if (handData.poses.Count > 0)
         {
             poseMixer = AnimationMixerPlayable.Create(graph, handData.poses.Count);
             poses     = new List <Pose>();
             for (int i = 0; i < handData.poses.Count; i++)
             {
                 var poseClip = handData.poses[i];
                 if (poseClip)
                 {
                     var pose = new Pose();
                     pose.playable = AnimationClipPlayable.Create(graph, handData.poses[i]);
                     pose.clip     = handData.poses[i];
                     poses.Add(pose);
                     graph.Connect(pose.playable, 0, poseMixer, i);
                     poseMixer.SetInputWeight(i, 0);
                 }
                 poseMixer.SetInputWeight(pose, 1);
             }
             if (poses.Count > 0)
             {
                 graph.Connect(poseMixer, 0, handMixer, 1);
                 handMixer.SetInputWeight(1, 0);
             }
         }
         var playableOutput = AnimationPlayableOutput.Create(graph, "Hand Controller", GetComponentInChildren <Animator>());
         playableOutput.SetSourcePlayable(handMixer);
         initialized = true;
         graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
         graph.Play();
     }
     else
     {
         initialized = false;
     }
 }
예제 #2
0
        public void SetupTopology(RuntimeAnimatorController controller = null)
        {
            controller             = controller ?? characterAnimator.animator.runtimeAnimatorController;
            controller             = controller ?? this.runtimeController;
            this.runtimeController = controller;

            this.characterAnimator.animator.runtimeAnimatorController = null;

            if (!this.graph.Equals(null) && this.graph.IsValid())
            {
                this.graph.Destroy();
            }
            this.graph = PlayableGraph.Create();

            this.characterAnimator.animator.playableGraph.Destroy();

            this.animationOutput = AnimationPlayableOutput.Create(
                this.graph,
                NAME_ANIMATOR_OUTPUT,
                this.characterAnimator.animator
                );

            Playable previousPlayable = AnimatorControllerPlayable.Create(
                this.graph,
                this.runtimeController
                );

            this.states = new StateNode[MAX_LAYERS];
            for (int i = 0; i < MAX_LAYERS; ++i)
            {
                this.states[i]   = new StateNode();
                previousPlayable = this.states[i].statesNorm.Setup(this.graph, previousPlayable);
                previousPlayable = this.states[i].statesMask.Setup(this.graph, previousPlayable);
            }

            this.gesture     = new GestureAnimation();
            previousPlayable = this.gesture.Setup(this.graph, previousPlayable);

            this.gestureMask = new GestureMaskAnimation();
            previousPlayable = this.gestureMask.Setup(this.graph, previousPlayable);

            this.animationOutput.SetSourcePlayable(previousPlayable);

            #if UNITY_2018_2_OR_NEWER
            this.animationOutput.SetSourceOutputPort(0);
            #else
            this.animationOutput.SetSourceInputPort(0);
            #endif

            this.graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
            this.graph.Play();
        }
예제 #3
0
    //Use this instead of the MonoBehaviour Start Function
    protected override void Init()
    {
        animator = GetComponent <Animator>();

        playableGraph = PlayableGraph.Create();
        //playableGraph.SetTimeUpdateMode(DirectorUpdateMode.Manual);

        playableOutput = AnimationPlayableOutput.Create(playableGraph, "Anim", animator);

        playableClip = AnimationClipPlayable.Create(playableGraph, clip);

        playableOutput.SetSourcePlayable(playableClip);
    }
예제 #4
0
    public void Awake()
    {
        graph = PlayableGraph.Create();
        graph.SetTimeUpdateMode(mode);

        playableOutput = AnimationPlayableOutput.Create(graph, "EthanWithPlayable", GetComponent <Animator>());

        var runClip = AnimationClipPlayable.Create(graph, run);

        playableOutput.SetSourcePlayable(runClip);

        graph.Play();
    }
예제 #5
0
파일: Move.cs 프로젝트: keainala/goodGame
 // Start is called before the first frame update
 void Start()
 {
     OriginPos               = transform.position;
     OriginPos.y             = OriginPos.y + 0.1f;
     playableGraph           = PlayableGraph.Create();
     animationPlayableOutput = AnimationPlayableOutput.Create(playableGraph, "", GetComponent <Animator>());
     //AnimationLayerMixerPlayable animationLayerMixerPlayable = AnimationLayerMixerPlayable.Create(playableGraph, 3);
     ///animationPlayableOutput.SetSourcePlayable(animationLayerMixerPlayable);
     jumpClip = Resources.Load("Jump") as AnimationClip;
     runClip  = Resources.Load("Run") as AnimationClip;
     idleClip = Resources.Load("Idle") as AnimationClip;
     //AnimationClip[] animationClip = Resources.LoadAll<AnimationClip>("BasicMotions@Jump01");
 }
예제 #6
0
        private void Awake()
        {
            PlayableGraph = PlayableGraph.Create("Animation Graph");

            RootNode = new MixerNode();
            RootNode.CreatePlayable(PlayableGraph);

            PlayableOutput = AnimationPlayableOutput.Create(PlayableGraph, "Animation Output", GetComponent <Animator>());
            PlayableOutput.SetSourcePlayable(RootNode.Playable);
            PlayableOutput.SetAnimationStreamSource(AnimationStreamSource.DefaultValues);

            PlayableGraph.Play();
        }
예제 #7
0
    public void Configure(Animator animator, EnemyAnimationConfig config)
    {
        hasAppearClip    = config.Appear;
        hasDisappearClip = config.Disappear;

        graph = PlayableGraph.Create();
        graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
        mixer = AnimationMixerPlayable.Create(
            graph, hasAppearClip || hasDisappearClip ? 6 : 4
            );

        var clip = AnimationClipPlayable.Create(graph, config.Move);

        clip.Pause();
        mixer.ConnectInput((int)Clip.Move, clip, 0);

        clip = AnimationClipPlayable.Create(graph, config.Intro);
        clip.SetDuration(config.Intro.length);
        clip.Pause();
        mixer.ConnectInput((int)Clip.Intro, clip, 0);

        clip = AnimationClipPlayable.Create(graph, config.Outro);
        clip.SetDuration(config.Outro.length);
        clip.Pause();
        mixer.ConnectInput((int)Clip.Outro, clip, 0);

        clip = AnimationClipPlayable.Create(graph, config.Dying);
        clip.SetDuration(config.Dying.length);
        clip.Pause();
        mixer.ConnectInput((int)Clip.Dying, clip, 0);

        if (hasAppearClip)
        {
            clip = AnimationClipPlayable.Create(graph, config.Appear);
            clip.SetDuration(config.Appear.length);
            clip.Pause();
            mixer.ConnectInput((int)Clip.Appear, clip, 0);
        }

        if (hasDisappearClip)
        {
            clip = AnimationClipPlayable.Create(graph, config.Disappear);
            clip.SetDuration(config.Disappear.length);
            clip.Pause();
            mixer.ConnectInput((int)Clip.Disappear, clip, 0);
        }

        var output = AnimationPlayableOutput.Create(graph, "Enemy", animator);

        output.SetSourcePlayable(mixer);
    }
예제 #8
0
    //private AnimatorController animController;

    void Start()
    {
        playableGraph = PlayableGraph.Create("ClairePlayableGraph");

        playableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);

        var playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", GetComponent <Animator>());

        // Create a Mixer
        AnimationLayerMixerPlayable mixerLayerPlayable = AnimationLayerMixerPlayable.Create(playableGraph, 2);


        playableOutput.SetSourcePlayable(mixerLayerPlayable);

        // Wrap the clip in a playable

        var clipPlayable = AnimationClipPlayable.Create(playableGraph, clip);

        //var clipPlayable1 = AnimationClipPlayable.Create(playableGraph, clip1);


        // Wrap AnimController

        runtimeAnimController = GetComponent <Animator>().runtimeAnimatorController;
        //animController = (AnimatorController)animator.runtimeAnimatorController;
        var runtimeAnimControllerPlayable = AnimatorControllerPlayable.Create(playableGraph, runtimeAnimController);


        // Connect to Mixer

        playableGraph.Connect(runtimeAnimControllerPlayable, 0, mixerLayerPlayable, 1);
        playableGraph.Connect(clipPlayable, 0, mixerLayerPlayable, 0);

        mixerLayerPlayable.SetInputWeight(0, 1.0f);
        mixerLayerPlayable.SetInputWeight(1, 1.0f);

        //mixerLayerPlayable.SetLayerAdditive(0, true);
        mixerLayerPlayable.SetLayerAdditive(1, true);
        Debug.Log("Is layer 0 additive: " + mixerLayerPlayable.IsLayerAdditive(0));
        Debug.Log("Is layer 1 additive: " + mixerLayerPlayable.IsLayerAdditive(1));

        //mixerLayerPlayable.SetLayerMaskFromAvatarMask(1, headMask);

        // Connect the Playable to an output

        //playableOutput.SetSourcePlayable(clipPlayable);

        // Plays the Graph.

        playableGraph.Play();
    }
예제 #9
0
        void Start()
        {
            playableGraph = PlayableGraph.Create();
            var playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", GetComponent <Animator>());

            mixerPlayable = AnimationMixerPlayable.Create(playableGraph, 2);
            playableOutput.SetSourcePlayable(mixerPlayable);
            var clipPlayable0 = AnimationClipPlayable.Create(playableGraph, clip0);
            var clipPlayable1 = AnimationClipPlayable.Create(playableGraph, clip1);

            playableGraph.Connect(clipPlayable0, 0, mixerPlayable, 0);
            playableGraph.Connect(clipPlayable1, 0, mixerPlayable, 1);
            playableGraph.Play();
        }
예제 #10
0
    void Start()
    {
        playableGraph = PlayableGraph.Create();
        var animationOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", GetComponent <Animator>());
        var audioOutput     = AudioPlayableOutput.Create(playableGraph, "Audio", GetComponent <AudioSource>());

        var animationClipPlayable = AnimationClipPlayable.Create(playableGraph, animationClip);
        var audioClipPlayable     = AudioClipPlayable.Create(playableGraph, audioClip, true);

        animationOutput.SetSourcePlayable(animationClipPlayable);
        audioOutput.SetSourcePlayable(audioClipPlayable);

        playableGraph.Play();
    }
예제 #11
0
        public static AnimatorPlayable alloc(string p_graphName, Animator p_animator)
        {
            AnimatorPlayable l_instance = new AnimatorPlayable();

            l_instance.Animator            = p_animator;
            l_instance.GlobalPlayableGraph = PlayableGraph.Create(p_graphName);
            l_instance.GlobalPlayableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
            var playableOutput = AnimationPlayableOutput.Create(l_instance.GlobalPlayableGraph, "Animation", p_animator);

            l_instance.AnimationLayerMixerPlayable = AnimationLayerMixerPlayable.Create(l_instance.GlobalPlayableGraph);
            PlayableOutputExtensions.SetSourcePlayable(playableOutput, l_instance.AnimationLayerMixerPlayable);
            l_instance.GlobalPlayableGraph.Play();
            return(l_instance);
        }
예제 #12
0
    void Start()
    {
        graph = PlayableGraph.Create("BlendController");
        AnimationPlayableOutput output = AnimationPlayableOutput.Create(graph, "Animation", GetComponent <Animator>());

        mixer = AnimationMixerPlayable.Create(graph, 2);
        output.SetSourcePlayable(mixer);
        AnimationClipPlayable      clipP = AnimationClipPlayable.Create(graph, clip);
        AnimatorControllerPlayable ctrlP = AnimatorControllerPlayable.Create(graph, controller);

        graph.Connect(clipP, 0, mixer, 0);
        graph.Connect(ctrlP, 0, mixer, 1);
        graph.Play();
    }
예제 #13
0
        public void Convert(Entity entity, EntityManager entityManager,
                            GameObjectConversionSystem conversionSystem)
        {
            _graph = PlayableGraph.Create();
            _graph.SetTimeUpdateMode(DirectorUpdateMode.Manual);

            var animator = GetComponentInChildren <Animator>();

            AnimationPlayableOutput.Create(_graph, name + " Animation", animator);

            entityManager.AddComponent(entity, typeof(PlayerConfig));
            entityManager.AddComponent(entity, typeof(PlayerComponent));
            entityManager.AddComponent(entity, typeof(PlayerInputComponent));
            entityManager.AddComponent(entity, typeof(CharacterFrame));
            entityManager.AddComponent(entity, typeof(CameraTarget));
            // Copy the player's position and transforms from the Entity to the GameObject
            entityManager.AddComponentData(entity, new PlayerCharacter {
                PlayableGraph   = _graph,
                StateController = _frameData != null ?
                                  _frameData.BuildController(new CharacterControllerBuildParams {
                    Graph = _graph
                }) :
                                  default(BlobAssetReference <CharacterStateController>)
            });

            // Copy the player's position and transforms from the Entity to the GameObject
            entityManager.AddComponent <CopyTransformToGameObject>(entity);
            entityManager.AddComponentObject(entity, transform);

            // Allocate player hitboxes for immediate player use.
            CreatePlayerHitboxes(entity, entityManager, CharacterFrame.kMaxPlayerHitboxCount);

            // Constrain players to only allow for X/Y movement and zero rotation.
            conversionSystem.World.GetOrCreateSystem <EndJointConversionSystem>().CreateJointEntity(
                this, new PhysicsConstrainedBodyPair(conversionSystem.GetPrimaryEntity(this), Entity.Null, false),
                CreateRigidbodyConstraints(Math.DecomposeRigidBodyTransform(transform.localToWorldMatrix))
                );

            // Copy bone positions and transforms from the GameObject to the Entities
            foreach (var child in GetComponentsInChildren <Transform>())
            {
                if (child == transform)
                {
                    continue;
                }
                Entity childEntity = conversionSystem.GetPrimaryEntity(child.gameObject);
                entityManager.AddComponent <CopyTransformFromGameObject>(childEntity);
                entityManager.AddComponentObject(childEntity, child);
            }
        }
예제 #14
0
    void Awake()
    {
        playableGraph = PlayableGraph.Create();
        playableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);

        var playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", GetComponent <Animator>());

        clipPlayable = AnimationClipPlayable.Create(playableGraph, clip);

        playableOutput.SetSourcePlayable(clipPlayable);

        playableGraph.Play();
        speed = 0.0f;
    }
예제 #15
0
    private void InitAnimationController()
    {
        PlayableGraphObject = PlayableGraph.Create();
        var playableOutput = AnimationPlayableOutput.Create(PlayableGraphObject, "Animation", AnimatorComponent);

        mixerPlayable = AnimationMixerPlayable.Create(PlayableGraphObject, AnimationsDictionary.Count);
        playableOutput.SetSourcePlayable(mixerPlayable);
        foreach (var anim in AnimationsDictionary)
        {
            var  clipPlayable0 = AnimationClipPlayable.Create(PlayableGraphObject, anim.Value);
            bool isConnected   = PlayableGraphObject.Connect(clipPlayable0, 0, mixerPlayable, anim.Key);
        }
        PlayableGraphObject.Play();
    }
    void Start()
    {
        m_Graph = PlayableGraph.Create("NotificationGraph");
        var output = ScriptPlayableOutput.Create(m_Graph, "NotificationOutput");

        //Create and register a receiver
        m_Receiver = new ReceiverExample();
        output.AddNotificationReceiver(m_Receiver);

        //Push a notification on the output
        output.PushNotification(Playable.Null, new MyNotification());

        m_Graph.Play();
    }
예제 #17
0
        private void Start()
        {
            playableGraph = PlayableGraph.Create();
            var playableOutPut = AnimationPlayableOutput.Create(playableGraph, "Animation", GetComponent <Animator>());

            mixerPlayable = AnimationMixerPlayable.Create(playableGraph, 2);
            playableOutPut.SetSourcePlayable(mixerPlayable);
            var clipPlayable = AnimationClipPlayable.Create(playableGraph, clip);
            var ctrlPlayable = AnimatorControllerPlayable.Create(playableGraph, controller);

            playableGraph.Connect(clipPlayable, 0, mixerPlayable, 0);
            playableGraph.Connect(ctrlPlayable, 0, mixerPlayable, 1);
            playableGraph.Play();
        }
예제 #18
0
    void OnEnable()
    {
        // Load animation clips.
        var idleClip = SampleUtility.LoadAnimationClipFromFbx("DefaultMale/Models/DefaultMale_Generic", "Idle");
        var romClip  = SampleUtility.LoadAnimationClipFromFbx("DefaultMale/Models/DefaultMale_Generic", "ROM");

        if (idleClip == null || romClip == null)
        {
            return;
        }

        var animator = GetComponent <Animator>();

        // Get all the transforms in the hierarchy.
        var transforms    = animator.transform.GetComponentsInChildren <Transform>();
        var numTransforms = transforms.Length - 1;

        // Fill native arrays (all the bones have a weight of 1.0).
        m_Handles     = new NativeArray <TransformStreamHandle>(numTransforms, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
        m_BoneWeights = new NativeArray <float>(numTransforms, Allocator.Persistent, NativeArrayOptions.ClearMemory);
        for (var i = 0; i < numTransforms; ++i)
        {
            m_Handles[i]     = animator.BindStreamTransform(transforms[i + 1]);
            m_BoneWeights[i] = 1.0f;
        }

        // Create job.
        var job = new MixerJob()
        {
            handles     = m_Handles,
            boneWeights = m_BoneWeights,
            weight      = 0.0f
        };

        // Create graph with custom mixer.
        m_Graph = PlayableGraph.Create("SimpleMixer");
        m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);

        m_CustomMixerPlayable = AnimationScriptPlayable.Create(m_Graph, job);
        m_CustomMixerPlayable.SetProcessInputs(false);
        m_CustomMixerPlayable.AddInput(AnimationClipPlayable.Create(m_Graph, idleClip), 0, 1.0f);
        m_CustomMixerPlayable.AddInput(AnimationClipPlayable.Create(m_Graph, romClip), 0, 1.0f);

        var output = AnimationPlayableOutput.Create(m_Graph, "output", animator);

        output.SetSourcePlayable(m_CustomMixerPlayable);

        m_Graph.Play();
    }
예제 #19
0
    protected void Init()
    {
        if (mInitialized)
        {
            return;
        }

        mGraph = PlayableGraph.Create(mGraphName);
        mGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);

        mBasePlayable         = CreatePlayable();
        mBasePlayable.onDone += OnPlayableDone;

        mInitialized = true;
    }
        private void Awake()
        {
            _Graph = PlayableGraph.Create();

            var animOutput = AnimationPlayableOutput.Create(_Graph, "AnimationOutput", null);

            _sourcePlayable = ScriptPlayable <CustomPlayable> .Create(_Graph, 1);

            animOutput.SetSourcePlayable(_sourcePlayable);

            _sourcePlayable.SetDuration(Duration);
            RegisterAnimations();

            _Graph.Play();
        }
예제 #21
0
    void Start()
    {
        graph = PlayableGraph.Create("PlayQueue");
        var playQueueP = ScriptPlayable <PlayQueuePlayable> .Create(graph);

        var playQueue = playQueueP.GetBehaviour();

        playQueue.Init(clipsToPlay, playQueueP, graph);
        var output = AnimationPlayableOutput.Create(graph, "Animation", GetComponent <Animator>());

        output.SetSourcePlayable(playQueueP);
        output.SetSourceOutputPort(0);

        graph.Play();
    }
예제 #22
0
        private void Awake()
        {
            EnsureVersionUpgraded();
            hasAwoken = true;

            if (layers.Length == 0)
            {
                return;
            }

            //The playable graph is a directed graph of Playables.
            graph = PlayableGraph.Create();

            // The AnimationPlayableOutput links the graph with an animator that plays the graph.
            // I think we can ditch the animator, but the documentation is kinda sparse!
            outputAnimator = gameObject.EnsureComponent <Animator>();
            AnimationPlayableOutput animOutput = AnimationPlayableOutput.Create(graph, $"{name}_animation_player", outputAnimator);

            for (var i = 0; i < layers.Length; i++)
            {
                layers[i].InitializeSelf(graph);
            }

            if (layers.Length <= 1)
            {
                rootPlayable = layers[0].stateMixer;
            }
            else
            {
                var layerMixer = AnimationLayerMixerPlayable.Create(graph, layers.Length);

                for (var i = 0; i < layers.Length; i++)
                {
                    layers[i].InitializeLayerBlending(graph, i, layerMixer);
                }

                rootPlayable = layerMixer;
            }

            animOutput.SetSourcePlayable(rootPlayable);

            //fun fact: default is DSPClock!
            graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
            graph.Play();

            visualizerClientName = name + " AnimationPlayer";
            GraphVisualizerClient.Show(graph, visualizerClientName);
        }
예제 #23
0
    void Start()
    {
        m_Graph = PlayableGraph.Create();
        var custPlayable = ScriptPlayable <CustomPlayable> .Create(m_Graph);

        var playQueue = custPlayable.GetBehaviour();

        playQueue.Initialize(clipsToPlay, custPlayable, m_Graph);

        var playableOutput = AnimationPlayableOutput.Create(m_Graph, "Animation", GetComponent <Animator>());

        playableOutput.SetSourcePlayable(custPlayable);
        playableOutput.SetSourceInputPort(0);

        m_Graph.Play();
    }
예제 #24
0
    private void Start()
    {
        _playableGraph = PlayableGraph.Create();
        var playQueuePlayable = ScriptPlayable <PlayQueuePlayable> .Create(_playableGraph);

        var playQueue = playQueuePlayable.GetBehaviour();

        playQueue.Initialize(clipsToPlay, playQueuePlayable, _playableGraph);

        var playableOutput = AnimationPlayableOutput.Create(
            _playableGraph, "Animation", GetComponent <Animator>());

        playableOutput.SetSourcePlayable(playQueuePlayable, 0);

        _playableGraph.Play();
    }
    // Token: 0x06000002 RID: 2 RVA: 0x00002058 File Offset: 0x00000458
    private void Start()
    {
        graph = PlayableGraph.Create();
        AnimationClipPlayable b = AnimationClipPlayable.Create(graph, clip);

        b.SetSpeed(animspeed);

        mixer = AnimationMixerPlayable.Create(graph);
        mixer.ConnectInput(0, b, 0);
        mixer.SetInputWeight(0, 1);

        var output = AnimationPlayableOutput.Create(graph, "output", GetComponent <Animator> ());

        output.SetSourcePlayable(mixer);
        graph.Play();
    }
예제 #26
0
        public void StartPreviewing(AnimationState state)
        {
            IsShowingPreview      = true;
            currentPreviewedState = state;

            previewGraph = PlayableGraph.Create();
            var animator   = animationPlayer.gameObject.EnsureComponent <Animator>();
            var animOutput = AnimationPlayableOutput.Create(previewGraph, "AnimationOutput", animator);

            animOutput.SetSourcePlayable(state.GeneratePlayable(previewGraph, new Dictionary <string, List <BlendTreeController1D> >(),
                                                                new Dictionary <string, List <BlendTreeController2D> >(),
                                                                new Dictionary <string, float>()));

            previewGraph.SetTimeUpdateMode(DirectorUpdateMode.Manual);
            previewGraph.Play();
        }
    private void Initialize()
    {
        if (m_Initialized)
        {
            return;
        }

        m_Animator             = GetComponent <Animator>();
        m_Animator.updateMode  = m_AnimatePhysics ? AnimatorUpdateMode.AnimatePhysics : AnimatorUpdateMode.Normal;
        m_Animator.cullingMode = m_CullingMode;
        m_Graph = PlayableGraph.Create();
        m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
        // 先自行new一個出來再當作template塞進Create方法(應該是為了確保Constructor執行)
        SimpleAnimationPlayable template = new SimpleAnimationPlayable();

        var playable = ScriptPlayable <SimpleAnimationPlayable> .Create(m_Graph, template, 1);

        m_Playable         = playable.GetBehaviour();
        m_Playable.onDone += OnPlayableDone;
        if (m_States == null)
        {
            m_States    = new EditorState[1];
            m_States[0] = new EditorState();
            m_States[0].defaultState = true;
            m_States[0].name         = "Default";
        }


        if (m_States != null)
        {
            foreach (var state in m_States)
            {
                if (state.clip)
                {
                    m_Playable.AddClip(state.clip, state.name);
                }
            }
        }

        EnsureDefaultStateExists();

        // 綁定m_Aniamtor採用起點為m_Playable的graph(懶人寫法不需要再自行處理PlayableOutput)
        AnimationPlayableUtilities.Play(m_Animator, m_Playable.playable, m_Graph);
        Play();
        Kick();
        m_Initialized = true;
    }
예제 #28
0
    private void Initialize()
    {
        if (m_Initialized)
        {
            return;
        }

        m_Animator             = GetComponent <Animator>();
        m_Animator.updateMode  = m_AnimatePhysics ? AnimatorUpdateMode.AnimatePhysics : AnimatorUpdateMode.Normal;
        m_Animator.cullingMode = m_CullingMode;
        m_Graph = PlayableGraph.Create();
        m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
        SimpleAnimationPlayable template = new SimpleAnimationPlayable();

        Debug.Log(m_Graph.GetPlayableCount());

        var playable = ScriptPlayable <SimpleAnimationPlayable> .Create(m_Graph, template, 1);

        m_Playable         = playable.GetBehaviour();
        m_Playable.onDone += OnPlayableDone;
        if (m_States == null)
        {
            m_States    = new EditorState[1];
            m_States[0] = new EditorState();
            m_States[0].defaultState = true;
            m_States[0].name         = "Default";
        }


        if (m_States != null)
        {
            foreach (var state in m_States)
            {
                if (state.clip)
                {
                    m_Playable.AddClip(state.clip, state.name);
                }
            }
        }

        EnsureDefaultStateExists();

        AnimationPlayableUtilities.Play(m_Animator, m_Playable.playable, m_Graph);
        Play();
        Kick();
        m_Initialized = true;
    }
    public static int Create_s(IntPtr l)
    {
        int result;

        try
        {
            PlayableGraph playableGraph = PlayableGraph.Create();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, playableGraph);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
예제 #30
0
    void Start()
    {
        graph = PlayableGraph.Create("PauseSubGraphAnimation");
        AnimationPlayableOutput output = AnimationPlayableOutput.Create(graph, "Animation", GetComponent <Animator>());

        mixer = AnimationLayerMixerPlayable.Create(graph, 2);
        output.SetSourcePlayable(mixer);
        clipPlay0 = AnimationClipPlayable.Create(graph, clip0);
        clipPlay1 = AnimationClipPlayable.Create(graph, clip1);
        graph.Connect(clipPlay0, 0, mixer, 0);
        graph.Connect(clipPlay1, 0, mixer, 1);
        mixer.SetInputWeight(0, 1f);
        mixer.SetInputWeight(1, 1f);


        graph.Play();
    }