36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
using UnityEngine.Timeline;
|
|
|
|
namespace MaterialTrack.Group
|
|
{
|
|
[TrackColor(0.1f, 0.5f, 0.2f)]
|
|
[TrackBindingType(typeof(MaterialGroup))]
|
|
[TrackClipType(typeof(MaterialGroupClip))]
|
|
public class MaterialGroupTrack : TrackAsset
|
|
{
|
|
public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
|
|
{
|
|
var mixerPlayable = ScriptPlayable<MaterialGroupMixer>.Create(graph, inputCount);
|
|
var mixerBehaviour = mixerPlayable.GetBehaviour();
|
|
|
|
// Initialize clips
|
|
foreach (TimelineClip clip in GetClips())
|
|
{
|
|
var asset = clip.asset as MaterialGroupClip;
|
|
if (asset != null)
|
|
{
|
|
// Set display name of each clip
|
|
var data = asset.template;
|
|
clip.displayName = RendererTrack.BuildClipName(data);
|
|
|
|
// Provide the mixer to the clip's behaviour so the Inspector can find the materials
|
|
data.mixer = mixerBehaviour;
|
|
}
|
|
}
|
|
|
|
return mixerPlayable;
|
|
}
|
|
}
|
|
}
|