Native plugin to use ReplayKit with Unity.
Native plugin to use ReplayKit with Unity.
The ReplayKit framework provides the ability to record video and audio within your app and share it.
Swift-implemented version is here.
Download unity-replay-kit-bridge.unitypackage from link below:
Notice: Swift-implemented version requires unity-swift.
See Example/Assets/Main/Main.unity and UIController.cs.
// Check whether the screen recorder is available.
if (ReplayKitBridge.IsScreenRecorderAvailable) {
Debug.Log("Screen recorder is available.");
}
// Check whether the app is recording.
if (ReplayKitBridge.IsRecording) {
Debug.Log("Now recording.");
}
// Check whether the camera is enabled. (iOS 10 or later)
if (!ReplayKitBridge.IsCameraEnabled) {
// Enable the camera. (iOS 10 or later)
ReplayKitBridge.IsCameraEnabled = true;
}
// Check whether the microphone is enabled.
if (!ReplayKitBridge.IsMicrophoneEnabled) {
// Enable the microphone.
ReplayKitBridge.IsMicrophoneEnabled = true;
}
ReplayKitBridge.Instance.onStartRecordingCallback = () => {
// Called when recording has been started.
};
ReplayKitBridge.Instance.onStopRecordingCallback = () => {
// Called when recording has been stopped.
Time.timeScale = 0; // Pause scene while user is editting and sharing recorded screen.
ReplayKitBridge.PresentPreviewView(); // Present preview view.
};
ReplayKitBridge.Instance.onFinishPreviewCallback = (string activityType) => {
// Called when recorded video has been saved or when the done button has been pressed.
ReplayKitBridge.DismissPreviewView(); // Dismiss preview view.
Time.timeScale = 1; // Resume time scale.
};
ReplayKitBridge.Instance.onCancelRecordingCallback = () => {
// Called when recording has been stopped and discarded.
};
ReplayKitBridge.Instance.onStopRecordingWithErrorCallback = (string error) => {
// Called when recording has been stopped due to an error.
};
ReplayKitBridge.StartRecording(); // Start screen recording.
ReplayKitBridge.StopRecording(); // Stop screen recording.
ReplayKitBridge.CancelRecording(); // Stop and discard current screen recording.
ReplayKitBridge.PresentPreviewView(); // Present preview view.
ReplayKitBridge.DismissPreviewView(); // Dismiss preview view.
Camera Usage Description (NSCameraUsageDescription) is defined in UnityReplayKitBridge/Editor/Config.cs.
This value is written in Info.plist and displayed when the system prompts the user to allow access to the camera.
public const string CameraUsageDescription = "Screen recording";
iOS 9 or later
Unity 5.3.5f1
Xcode 7.3.1