Skip to content

Instantly share code, notes, and snippets.

@iwashihead
Last active September 12, 2016 05:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwashihead/209c47e1fdb4010cb57f to your computer and use it in GitHub Desktop.
Save iwashihead/209c47e1fdb4010cb57f to your computer and use it in GitHub Desktop.
Unityでスクリーンショットが完了するまでの待機するサンプル
public void OnTweet()
{
StartCoroutine(Share());
}
IEnumerator Share()
{
// スクリーンショットをとる
Application.CaptureScreenshot("image.png");
// インジケーター表示
#if UNITY_IPHONE
Handheld.SetActivityIndicatorStyle(iOSActivityIndicatorStyle.White);
#elif UNITY_ANDROID
Handheld.SetActivityIndicatorStyle(AndroidActivityIndicatorStyle.Small);
#endif
Handheld.StartActivityIndicator();
// スクリーンショットが保存されるまで待機
long filesize = 0;
float time = 0f;
while (filesize == 0)
{
yield return null;
//ファイルのサイズを取得
System.IO.FileInfo fi = new System.IO.FileInfo(imagePath);
if (fi != null) {
filesize = fi.Length;
}
}
// インジケーター非表示
Handheld.StopActivityIndicator();
// shareのテキスト内容
string tweet = "" + score + "100点を記録しました!!";
// 共有
SocialConnector.Share(tweet, GameDefine.APP_UR, imagePath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment