Experimental: this API is experimental and might be changed or removed in the future.

AnimationScriptPlayable.Create

매뉴얼로 전환
public static Experimental.Animations.AnimationScriptPlayable Create (Playables.PlayableGraph graph, T jobData, int inputCount);

파라미터

graphThe PlayableGraph object that will own the AnimationScriptPlayable.
jobThe IAnimationJob to execute when processing the playable.
inputCountThe number of inputs on the playable.

반환

AnimationScriptPlayable A new AnimationScriptPlayable linked to the PlayableGraph.

설명

Creates an AnimationScriptPlayable in the PlayableGraph.

This playable contains a job implementing an IAnimationJob. This interface defines two methods that will be called while processing the PlayableGraph.

Here is an example of how to create an AnimationScriptPlayable with a simple IAnimationJob:

using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Animations;

using UnityEngine.Experimental.Animations;

public struct AnimationJob : IAnimationJob { public int userData;

public void ProcessRootMotion(AnimationStream stream) { // This method is called during the root motion process pass. }

public void ProcessAnimation(AnimationStream stream) { // This method is called during the animation process pass. Debug.Log(string.Format("Value of the userData: {0}", userData)); } }

[RequireComponent(typeof(Animator))] public class AnimationScriptExample : MonoBehaviour { PlayableGraph m_Graph; AnimationScriptPlayable m_AnimationScriptPlayable;

void OnEnable() { m_Graph = PlayableGraph.Create("AnimationScriptExample"); var output = AnimationPlayableOutput.Create(m_Graph, "ouput", GetComponent<Animator>());

var animationJob = new AnimationJob(); m_AnimationScriptPlayable = AnimationScriptPlayable.Create(m_Graph, animationJob);

output.SetSourcePlayable(m_AnimationScriptPlayable); m_Graph.Play(); }

void Update() { var animationJob = m_AnimationScriptPlayable.GetJobData<AnimationJob>(); ++animationJob.userData; m_AnimationScriptPlayable.SetJobData(animationJob); }

void OnDisable() { m_Graph.Destroy(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961