Last active
June 5, 2021 03:12
-
-
Save kankikuchi/d323553f2a8083b0d101 to your computer and use it in GitHub Desktop.
Unity+AndroidでObbファイルを追加ダウンロード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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