44 lines
No EOL
1.2 KiB
C#
44 lines
No EOL
1.2 KiB
C#
using UnityEngine;
|
|
using UnityEditor.Recorder;
|
|
|
|
[RequireComponent(typeof(Camera))]
|
|
public class Recorder : MonoBehaviour
|
|
{
|
|
// Make this a prefab, that way you can move it between scenes
|
|
|
|
[Header("References")]
|
|
public Mesh mesh;
|
|
public MeshRenderer viewFinderRend;
|
|
|
|
Camera cam;
|
|
RecorderController recorder;
|
|
|
|
void Start()
|
|
{
|
|
cam = GetComponent<Camera>();
|
|
|
|
RenderTexture viewTex = new RenderTexture(512, 256, 16, RenderTextureFormat.Default);
|
|
viewTex.Create();
|
|
viewFinderRend.material.mainTexture = cam.targetTexture = viewTex;
|
|
|
|
RecorderControllerSettings settings = new RecorderControllerSettings();
|
|
recorder = new RecorderController(settings);
|
|
recorder.PrepareRecording();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
// Need to interact spatially with it, so buttons on the camera?
|
|
// nah to imprecise? esp if the camera is moving...
|
|
// then how do we get it to play nice with existing controls...
|
|
// its just one button for now so we can squeeze it in somewhere
|
|
|
|
// Hook up to unity recorder system (only works in editor :/)
|
|
// Record
|
|
// recorder.StartRecording();
|
|
// End
|
|
// recorder.StopRecording();
|
|
|
|
// Pause (nice in theory annoying in practice *need to trim and adjust clips)
|
|
}
|
|
} |