Demo entry 6428977

2222

   

Submitted by aaa on May 26, 2017 at 10:16
Language: C#. Code size: 986 Bytes.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;

public class NewBehaviourScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
        //创建一个 PlayableDirector 组件//
        PlayableDirector director = gameObject.AddComponent<PlayableDirector>();
        director.wrapMode = DirectorWrapMode.Loop;
        director.initialTime = 0.0f;
        director.timeUpdateMode = DirectorUpdateMode.GameTime;

        //从Resources文件夹加载一个 TimelineAsset 资源//
        TimelineAsset timeline = (TimelineAsset)Resources.Load("MyTimeline");

        //绑定一个Track到当前场景中的一个物体//
        TrackAsset track = (TrackAsset)timeline.outputs[0].sourceObject;
        director.SetGenericBinding(track, GameObject.Find("Sphere"));

        //播放这个Timeline//
        director.Play(timeline);
        //Fast forward the timeline//
        director.time = 42.0f;

        

    }
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).