GetSocial GIF Capturing Library Guide¶
The project goal is to help you create more engaging experiences we’ve created a GIF capturing library, so you can share gameplay GIFs via Smart Invites and Activity Feed.
The project on GitHub contains a demo app, so you can try out the features before adding to your project.
After downloading project and adding asset to your project, you’ll have access to all the source codes, feel free to improve it.
You can share your recorded content in a Smart Invite, or post it to an Activity Feed.
Integration guide¶
Setup¶
- Copy
Assets/GetSocialCapture
folder to your project - Add
GetSocialCapture
script to any of your Game components.
By defaultGetSocialCapture
records Main Camera’s rendered content. If you want to change this, set a different Camera instance
toCaptured Camera
variable. - If you want to show a preview of the recorded content add
GetSocialCapturePreview
Prefab to any of your screens. - You’re all set, let’s record something.
Recording¶
There are 2 different ways to create a recording, which can be selected using captureMode
property:
Continuous
, when script records camera’s content at a rate configured incaptureFrameRate
property and keeps the lastn
frames, specified bymaxCapturedFrames
property.Manual
, when script records camera’s content at the time whenCaptureFrame()
method is called. This mode is useful, e.g., in puzzle games and for making timelapse videos.
To finish a recording call StopCapture()
method. Until you start a new session by calling StartCapture
, the existing recording can be resumed, you only need to call ResumeCapture
.
When you recorded everything you wanted, call GenerateCapture
to generate the final gif
file.
Example - Continuous
mode¶
...
public GetSocialCapture capture;
...
// start recording if something interesting happens in the game
void RecordAction()
{
capture.StartCapture();
}
// stop recording
void ActionFinished()
{
capture.StopCapture();
// generate gif
capture.GenerateCapture(result =>
{
// use gif, like send it to your friends by using GetSocial SDK
});
}
Example - Manual
mode¶
...
public GetSocialCapture capture;
...
void Awake()
{
...
// set recording mode to `Manual`
capture.captureMode = GetSocialCapture.GetSocialCaptureMode.Manual;
}
// start recording if when puzzle level starts
void StartLevel()
{
capture.StartCapture();
}
// record the actual screen, like when a piece is moved in puzzle
void RecordStep()
{
capture.CaptureFrame();
}
// stop recording
void LevelFinished()
{
capture.StopCapture();
// generate gif
Action<byte[]> result = bytes =>
{
// generated gif returned as byte[]
byte[] gifContent = result.ToArray();
// use content, like send it to your friends by using GetSocial SDK
};
capture.GenerateCapture(result);
}
Customization¶
You can configure the recording using the following parameters:
captureFrameRate
- Number of captured frames per second.captureMode
- Capture mode, can beContinuous
orManual
.maxCapturedFrames
- Max. number of captured frames during the session.playbackFrameRate
- Number of displayed frames per second.loopPlayback
- Generated gif loops or played only once.
Tip
The length of recorded gif can be calculated using the following formula:
length = (maxCapturedFrames / captureFrameRate) * (captureFrameRate / playbackFrameRate)
Example - Quick¶
maxCapturedFrames = 50
captureFrameRate = 10
playback = 30
length = 1.5 sec
Example - Slow¶
maxCapturedFrames = 50
captureFrameRate = 30
playback = 10
length = 5 sec
Preview¶
If you want to display the recorded content in your game, add GetSocialCapturePreview
Prefab to any of your screens.
To start playback, call Play()
, to stop playback call Stop()
.
Example¶
...
public GetSocialCapture capture;
public GetSocialCapturePreview capturePreview;
....
// stop recording
void ActionFinished()
{
capture.StopCapture();
// show preview
capturePreview.Play();
}
Playback Customization¶
You can also customize playback:
playbackFrameRate
- Number of displayed frames per second.loopPlayback
- Preview loops or played only once.
The size and position of preview window can be changed in the Editor: