ReplayKit allows you to record the audio and video of your game, along
with user commentary through the microphone. Start a recording with the
StartRecording() function, and stop it with StopRecording(). You can
preview the recording with the Preview() function, which launches a separate video viewer.
Note: The exact Apple devices which have support for ReplayKit are:
1. iPhone 5S or later
2. iPad mini 2 or later
3. iPod Touch 6th generation
4. iPad Air or later.
#pragma strict
using UnityEngine.iOS;
using UnityEngine.Apple.ReplayKit;
public class Replay : MonoBehaviour
{
string lastError = "";
void OnGUI()
{
if (!ReplayKit.APIAvailable)
{
return;
}
var recording = ReplayKit.isRecording;
string caption = recording ? "Stop Recording" : "Start Recording";
if (GUI.Button(new Rect(10, 10, 500, 200), caption))
{
try
{
recording = !recording;
if (recording)
{
ReplayKit.StartRecording();
}
else
{
ReplayKit.StopRecording();
}
}
catch (Exception e)
{
lastError = e.ToString();
}
}
GUI.Label(new Rect(10, 220, 500, 50), "Last error: " + ReplayKit.lastError);
GUI.Label(new Rect(10, 280, 500, 50), "Last exception: " + lastError);
if (ReplayKit.recordingAvailable)
{
if (GUI.Button(new Rect(10, 350, 500, 200), "Preview"))
{
ReplayKit.Preview();
}
if (GUI.Button(new Rect(10, 560, 500, 200), "Discard"))
{
ReplayKit.Discard();
}
}
}
}
using System;
using UnityEngine;
#if PLATFORM_IOS
using UnityEngine.iOS;
using UnityEngine.Apple.ReplayKit;
public class Replay : MonoBehaviour
{
string lastError = "";
void OnGUI()
{
if (!ReplayKit.APIAvailable)
{
return;
}
var recording = ReplayKit.isRecording;
string caption = recording ? "Stop Recording" : "Start Recording";
if (GUI.Button(new Rect(10, 10, 500, 200), caption))
{
try
{
recording = !recording;
if (recording)
{
ReplayKit.StartRecording();
}
else
{
ReplayKit.StopRecording();
}
}
catch (Exception e)
{
lastError = e.ToString();
}
}
GUI.Label(new Rect(10, 220, 500, 50), "Last error: " + ReplayKit.lastError);
GUI.Label(new Rect(10, 280, 500, 50), "Last exception: " + lastError);
if (ReplayKit.recordingAvailable)
{
if (GUI.Button(new Rect(10, 350, 500, 200), "Preview"))
{
ReplayKit.Preview();
}
if (GUI.Button(new Rect(10, 560, 500, 200), "Discard"))
{
ReplayKit.Discard();
}
}
}
}
#endif