コード例 #1
0
        /// <inheritdoc />
        void IAnimationJobBinder.Update(IAnimationJob job, IAnimationJobData data)
        {
            Debug.Assert(data is TData && job is TJob);
            TData tData = (TData)data;

            Update((TJob)job, ref tData);
        }
コード例 #2
0
ファイル: RigUtils.cs プロジェクト: Galleom/Agin-AR
        public static IAnimationJob[] CreateAnimationJobs(Animator animator, IRigConstraint[] constraints)
        {
            if (constraints == null || constraints.Length == 0)
            {
                return(null);
            }

            IAnimationJob[] jobs = new IAnimationJob[constraints.Length];
            for (int i = 0; i < constraints.Length; ++i)
            {
                jobs[i] = constraints[i].CreateJob(animator);
            }

            return(jobs);
        }
コード例 #3
0
 /// <inheritdoc />
 AnimationScriptPlayable IAnimationJobBinder.CreatePlayable(PlayableGraph graph, IAnimationJob job)
 {
     Debug.Assert(job is TJob);
     return(AnimationScriptPlayable.Create(graph, (TJob)job));
 }
コード例 #4
0
 /// <inheritdoc />
 void IAnimationJobBinder.Destroy(IAnimationJob job)
 {
     Debug.Assert(job is TJob);
     Destroy((TJob)job);
 }
コード例 #5
0
        public void UpdateJob(IAnimationJob job)
        {
            IAnimationJobBinder binder = (IAnimationJobBinder)s_Binder;

            binder.Update(job, m_Constraint.data);
        }
コード例 #6
0
 public void DestroyJob(IAnimationJob job) => s_Binder.Destroy((TJob)job);
コード例 #7
0
ファイル: RigBuilder.cs プロジェクト: Galleom/Agin-AR
        public bool Build()
        {
            Clear();
            var animator = GetComponent <Animator>();

            if (animator == null || layers.Count == 0)
            {
                return(false);
            }

            string graphName = gameObject.transform.name + "_Rigs";

            graph = PlayableGraph.Create(graphName);
            graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);

            // Create sync scene to stream layer
            var syncLayerOutput = AnimationPlayableOutput.Create(graph, "syncSceneToStreamOutput", animator);

            syncLayerOutput.SetAnimationStreamSource(AnimationStreamSource.PreviousInputs);

            // Create all rig layers
            m_RigLayerData = new List <LayerData>(layers.Count);
            List <JobTransform> allRigReferences = new List <JobTransform>();

            foreach (var layer in layers)
            {
                if (!layer.Initialize(animator))
                {
                    continue;
                }

                LayerData data = new LayerData();
                data.output = AnimationPlayableOutput.Create(graph, "rigOutput", animator);
                data.output.SetAnimationStreamSource(AnimationStreamSource.PreviousInputs);
                data.playables = BuildRigPlayables(graph, layer.rig, ref data.output);

                layer.data = m_RigLayerData.Count;
                m_RigLayerData.Add(data);

                // Gather all references used by rig
                var references = RigUtils.GetAllConstraintReferences(animator, layer.rig.constraints);
                if (references != null)
                {
                    allRigReferences.AddRange(references);
                }

                references = RigUtils.GetAllRigTransformReferences(layer.rig);
                if (references != null)
                {
                    allRigReferences.AddRange(references);
                }
            }

            // Create sync to stream job with all rig references
            m_SyncSceneToStreamJobData = RigUtils.CreateSyncSceneToStreamData(allRigReferences.ToArray());
            if (m_SyncSceneToStreamJobData.IsValid())
            {
                m_SyncSceneToStreamJob = RigUtils.syncSceneToStreamBinder.Create(animator, m_SyncSceneToStreamJobData);
                syncLayerOutput.SetSourcePlayable(RigUtils.syncSceneToStreamBinder.CreatePlayable(graph, m_SyncSceneToStreamJob));
            }
            graph.Play();

            return(true);
        }