本项目演示如何创建自己的顶点动画着色器。场景不使用任何纹理或动画资源,所有内容都使用Shader Graph进行着色和动画处理。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

73 行
2.1 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
namespace UnityEditor.Recorder.Timeline
{
[DisplayName("Recorder Clip")]
public class RecorderClip : PlayableAsset, ITimelineClipAsset, ISerializationCallbackReceiver
{
[SerializeField]
public RecorderSettings settings;
internal bool needsDuplication;
static readonly Dictionary<RecorderSettings, RecorderClip> s_SettingsLookup = new Dictionary<RecorderSettings, RecorderClip>();
readonly SceneHook m_SceneHook = new SceneHook(Guid.NewGuid().ToString());
Type recorderType
{
get { return settings == null ? null : RecordersInventory.GetRecorderInfo(settings.GetType()).recorderType; }
}
public ClipCaps clipCaps
{
get { return ClipCaps.None; }
}
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
var playable = ScriptPlayable<RecorderPlayableBehaviour>.Create(graph);
var behaviour = playable.GetBehaviour();
if (recorderType != null && UnityHelpers.IsPlaying())
{
behaviour.session = m_SceneHook.CreateRecorderSession(settings);
}
return playable;
}
public void OnDestroy()
{
UnityHelpers.Destroy(settings, true);
}
public void OnBeforeSerialize()
{
if (settings != null)
{
RecorderClip clip;
if (s_SettingsLookup.TryGetValue(settings, out clip))
{
if (clip != this)
{
// Duplicate detected. Fix it
needsDuplication = true;
}
}
else
{
s_SettingsLookup[settings] = this;
}
}
}
public void OnAfterDeserialize()
{
// Nothing
}
}
}