Skip to content

Instantly share code, notes, and snippets.

@kankikuchi
Last active June 5, 2021 03:12
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 kankikuchi/d323553f2a8083b0d101 to your computer and use it in GitHub Desktop.
Save kankikuchi/d323553f2a8083b0d101 to your computer and use it in GitHub Desktop.
Unity+AndroidでObbファイルを追加ダウンロード
using UnityEngine;
using System.Collections;
public class LoadManager : MonoBehaviour {
//=================================================================================
//初期化
//=================================================================================
private void Awake(){
//プラットフォームがAndroidではない、または実機では無い場合はスルー
#if !UNITY_ANDROID || UNITY_EDITOR
MoveFirstScene();
return;
#endif
//ダウンロードされたobbが追加されるパス(外部ストレージの容量が足りないとnullが返って来る?)
string expansionPath = GooglePlayDownloader.GetExpansionFilePath();
if(expansionPath == null){
//ストレージの容量が足りない時の処理、警告を表示したり
}
else {
//obbがダウンロードされているか確認し、ダウンロードされていなければダウンロード実行。obbは二つ登録出来るので、mainとpatchの二つに付いて確認
string mainPath = GooglePlayDownloader.GetMainOBBPath(expansionPath);
string patchPath = GooglePlayDownloader.GetPatchOBBPath(expansionPath);
if( mainPath == null || patchPath == null )
{
GooglePlayDownloader.FetchOBB();
}
MoveFirstScene();
}
}
/// <summary>
/// 最初のシーンへ移動
/// </summary>
private void MoveFirstScene(){
Application.LoadLevel ("FirstScene");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment