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

94 行
3.4 KiB

#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Recorder;
using UnityEditor.Recorder.Input;
namespace UnityEngine.Recorder.Examples
{
public class RecorderExample : MonoBehaviour
{
RecorderController m_RecorderController;
void OnEnable()
{
var controllerSettings = ScriptableObject.CreateInstance<RecorderControllerSettings>();
m_RecorderController = new RecorderController(controllerSettings);
var animationOutputFolder = Application.dataPath + "/SampleRecordings";
var mediaOutputFolder = Application.dataPath + "../SampleRecordings";
//var outputFolder = Application.dataPath + "/SampleRecordings";
// Video
var videoRecorder = ScriptableObject.CreateInstance<MovieRecorderSettings>();
videoRecorder.name = "My Video Recorder";
videoRecorder.enabled = true;
videoRecorder.outputFormat = VideoRecorderOutputFormat.MP4;
videoRecorder.videoBitRateMode = VideoBitrateMode.Low;
videoRecorder.imageInputSettings = new GameViewInputSettings
{
outputWidth = 1920,
outputHeight = 1080
};
videoRecorder.audioInputSettings.preserveAudio = true;
videoRecorder.outputFile = mediaOutputFolder + "/video_" + DefaultWildcard.Take;
// Animation
var animationRecorder = ScriptableObject.CreateInstance<AnimationRecorderSettings>();
animationRecorder.name = "My Animation Recorder";
animationRecorder.enabled = true;
var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
animationRecorder.animationInputSettings = new AnimationInputSettings
{
gameObject = sphere,
recursive = true,
};
animationRecorder.animationInputSettings.AddComponentToRecord(typeof(Transform));
animationRecorder.outputFile = animationOutputFolder + "/animation_" + DefaultWildcard.GeneratePattern("GameObject") + "_" + DefaultWildcard.Take;
// Image Sequence
var imageRecorder = ScriptableObject.CreateInstance<ImageRecorderSettings>();
imageRecorder.name = "My Image Recorder";
imageRecorder.enabled = true;
imageRecorder.outputFormat = ImageRecorderOutputFormat.PNG;
imageRecorder.captureAlpha = true;
imageRecorder.outputFile = mediaOutputFolder + "/image_" + DefaultWildcard.Frame + "_" + DefaultWildcard.Take;
imageRecorder.imageInputSettings = new CameraInputSettings
{
source = ImageSource.MainCamera,
outputWidth = 1920,
outputHeight = 1080,
captureUI = true
};
// Setup Recording
controllerSettings.AddRecorderSettings(videoRecorder);
controllerSettings.AddRecorderSettings(animationRecorder);
controllerSettings.AddRecorderSettings(imageRecorder);
controllerSettings.SetRecordModeToManual();
controllerSettings.frameRate = 60.0f;
Options.verboseMode = false;
m_RecorderController.StartRecording();
}
void OnDisable()
{
m_RecorderController.StopRecording();
}
}
}
#endif