Select your preferred scripting language. All code snippets will be displayed in this language.
class in UnityEngine.Apple.ReplayKit
/
Implemented in:UnityEngine.CoreModule
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
CloseReplayKit is only available on certain iPhone, iPad and iPod Touch devices running iOS 9.0 or later.
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
APIAvailable | A boolean that indicates whether the ReplayKit API is available (where True means available). (Read Only) |
broadcastingAPIAvailable | A Boolean that indicates whether ReplayKit broadcasting API is available (true means available) (Read Only). Check the value of this property before making ReplayKit broadcasting API calls. On iOS versions prior to iOS 10, this property will have a value of false. |
broadcastURL | A string property that contains an URL used to redirect the user to an on-going or completed broadcast (Read Only). |
cameraEnabled | Camera enabled status, true, if camera enabled, false otherwise. |
isBroadcasting | Boolean property that indicates whether a broadcast is currently in progress (Read Only). |
isRecording | A boolean that indicates whether ReplayKit is making a recording (where True means a recording is in progress). (Read Only) |
lastError | A string value of the last error incurred by the ReplayKit: Either 'Failed to get Screen Recorder' or 'No recording available'. (Read Only) |
microphoneEnabled | Microphone enabled status, true, if microhone enabled, false otherwise. |
recordingAvailable | A boolean value that indicates that a new recording is available for preview (where True means available). (Read Only) |
Discard | Discard the current recording. |
HideCameraPreview | Hide the camera preview view. |
Preview | Preview the current recording |
ShowCameraPreviewAt | Shows camera preview at coordinates posX and posY. |
StartBroadcasting | Initiates and starts a new broadcast When StartBroadcast is called, user is presented with a broadcast provider selection screen, and then a broadcast setup screen. Once it is finished, a broadcast will be started, and the callback will be invoked. It will also be invoked in case of any error. |
StartRecording | Start a new recording. |
StopBroadcasting | Stops current broadcast. Will terminate currently on-going broadcast. If no broadcast is in progress, does nothing. |
StopRecording | Stop the current recording. |
BroadcastStatusCallback | Function called at the completion of broadcast startup. |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!