49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.Playables;
|
|||
|
|
|
|||
|
|
// A behaviour that is attached to a playable
|
|||
|
|
public class PlayableTest : PlayableBehaviour
|
|||
|
|
{
|
|||
|
|
public string testName;
|
|||
|
|
public int testInt;
|
|||
|
|
public Material _mat;
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Timeline<6E><65>ʱ<EFBFBD><CAB1>
|
|||
|
|
public override void OnGraphStart(Playable playable)
|
|||
|
|
{
|
|||
|
|
Debug.Log("TimeLine <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>Timeline<6E><65>ʱ<EFBFBD><CAB1>
|
|||
|
|
public override void OnGraphStop(Playable playable)
|
|||
|
|
{
|
|||
|
|
Debug.Log("TimeLine ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>Play
|
|||
|
|
public override void OnBehaviourPlay(Playable playable, FrameData info)
|
|||
|
|
{
|
|||
|
|
Debug.Log($"<22><><EFBFBD>뻬<EFBFBD><EBBBAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{testName},Int:{testInt},mat:{_mat.name}");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>߿<EFBFBD>ʼ<EFBFBD><CABC>ʱ<EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
public override void OnBehaviourPause(Playable playable, FrameData info)
|
|||
|
|
{
|
|||
|
|
Debug.Log($"Pause{testName},Int:{testInt}");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>Frame<6D>ط<EFBFBD><D8B7><EFBFBD><EFBFBD>ᴥ<EFBFBD><E1B4A5>
|
|||
|
|
public override void PrepareFrame(Playable playable, FrameData info)
|
|||
|
|
{
|
|||
|
|
double all = playable.GetDuration();
|
|||
|
|
double currentTime = playable.GetTime(); // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
//float framesPerSecond = info.playable.GetGraph().GetFrameRate(); // <20><>ȡÿ<C8A1><C3BF>֡<EFBFBD><D6A1>
|
|||
|
|
_mat.SetVector("_Value1", new Vector2(0.86f, (float)(currentTime * 0.04f / all)));
|
|||
|
|
Debug.Log($"{all}:Current Time: {currentTime}:cur:{(float)(currentTime * 0.04f / all)}");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|