IEnumerator AndroidHandleOBBDownload() { if (GooglePlayDownloader.RunningOnAndroid()) { string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath != null) { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); if (mainPath == null || patchPath == null) { message = "Downloading OBB file from the server. May take couple of minutes. Please wait!"; yield return(new WaitForSeconds(0)); // skip some frames to show the message yield return(new WaitForSeconds(0)); yield return(new WaitForSeconds(0)); GooglePlayDownloader.FetchOBB(); message = ""; } } } yield return(new WaitForSeconds(0)); }
void OnGUI() { if (!GooglePlayDownloader.RunningOnAndroid()) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "Use GooglePlayDownloader only on Android device!"); return; } expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "External storage is not available!"); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); if (mainPath == null) { Debug.LogWarning("DownloadObbExample==>FetchOBB-------1"); GooglePlayDownloader.FetchOBB(); Debug.LogWarning("DownloadObbExample==>FetchOBB-------2"); } StartCoroutine(loadLevel()); // GUI.Label(new Rect(10, 10, Screen.width-10, 20), "Main = ..." + ( mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length))); // GUI.Label(new Rect(10, 25, Screen.width-10, 20), "Patch = ..." + (patchPath == null ? " NOT AVAILABLE" : patchPath.Substring(expPath.Length))); // if (mainPath == null || patchPath == null) // if (GUI.Button(new Rect(10, 100, 100, 100), "Fetch OBBs")) // GooglePlayDownloader.FetchOBB(); } }
protected IEnumerator loadLevel() { string mainPath; do { yield return(new WaitForSeconds(0.5f)); mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); Debug.LogWarning("waiting mainPath " + mainPath); }while (mainPath == null); SceneManager.LoadScene("LoadingPage"); // if (downloadStarted == false) // { // downloadStarted = true; // // string uri = "file://" + mainPath; // log("downloading " + uri); // WWW www = WWW.LoadFromCacheOrDownload(uri, 0); // // // Wait for download to complete // yield return www; // // if (www.error != null) // { // log("wwww error " + www.error); // } // else // { // Application.LoadLevel(nextScene); // } // } }
void OnGUI() { if (!GooglePlayDownloader.RunningOnAndroid()) { return; } else if (PlayerPrefs.GetInt("obbLoaded", 0) == 0) { string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "External storage is not available!"); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); if (mainPath == null) { GooglePlayDownloader.FetchOBB(); } PlayerPrefs.SetInt("obbLoaded", 1); PlayerPrefs.Save(); } } }
public bool CheckGoogleResource() { if (Application.isEditor) { return(true); } if (GameDefines.OutputVerDefs == OutputVersionDefs.WPay) { if (!GooglePlayDownloader.RunningOnAndroid()) { Debug.Log("Use GooglePlayDownloader only on Android device!"); return(false); } string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { Debug.Log("External storage is not available!"); return(false); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); Debug.Log("Main = ..." + (mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length))); if (mainPath == null /*|| patchPath == null*/) { GooglePlayDownloader.FetchOBB(); return(false); } } } return(true); }
protected IEnumerator loadLevel() { string mainPath; do { yield return(new WaitForSeconds(0.5f)); mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); Debug.Log("waiting mainPath " + mainPath); }while(mainPath == null); if (downloadStarted == false) { downloadStarted = true; string uri = "file://" + mainPath; Debug.Log("downloading " + uri); WWW www = WWW.LoadFromCacheOrDownload(uri, 0); // Wait for download to complete yield return(www); if (www.error != null) { Debug.Log("wwww error " + www.error); } else { Application.LoadLevel(nextScene); } } }
void OnGUI() { if (!GooglePlayDownloader.RunningOnAndroid()) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "Use GooglePlayDownloader only on Android device!"); return; } string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "External storage is not available!"); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "Main = ..." + (mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length))); GUI.Label(new Rect(10, 25, Screen.width - 10, 20), "Patch = ..." + (patchPath == null ? " NOT AVAILABLE" : patchPath.Substring(expPath.Length))); if (mainPath == null || patchPath == null) { if (GUI.Button(new Rect(10, 100, 100, 100), "Fetch OBBs")) { GooglePlayDownloader.FetchOBB(); } } } }
protected IEnumerator WaitForObbDownLoadOver() { string mainPath; do { yield return(new WaitForSeconds(0.5f)); string expPath = GooglePlayDownloader.GetExpansionFilePath(); Debug.Log("expPath is : " + expPath); mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); Debug.Log("waiting mainPath " + mainPath); }while(mainPath == null); string[] files = Directory.GetFiles("/data/data/com.cyou.tlyd.android.tw/databases/"); for (int i = 0; i < files.Length; i++) { //delete obb downloads' info; if (files[i].Contains("DownloadsDB")) { Debug.Log("delete: " + files[i]); File.Delete(files[i]); } } Application.LoadLevel(Utils.UI_NAME_Login); }
private void CheckObb() { #if !UNITY_EDITOR && UNITY_ANDROID bool install = true; if (!GooglePlayDownloader.RunningOnAndroid()) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "Use GooglePlayDownloader only on Android device!"); return; } string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "External storage is not available!"); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); //GUI.Label(new Rect(10, 10, Screen.width-10, 20), "Main = ..." + ( mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length))); //GUI.Label(new Rect(10, 25, Screen.width-10, 20), "Patch = ..." + (patchPath == null ? " NOT AVAILABLE" : patchPath.Substring(expPath.Length))); if ((mainPath == null || patchPath == null) && install) { //if (GUI.Button(new Rect(10, 100, 100, 100), "Fetch OBBs")) install = false; } GooglePlayDownloader.FetchOBB(); } #endif }
void Start() { expPath = GooglePlayDownloader.GetExpansionFilePath(); string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); StartCoroutine(loadLevel()); }
protected IEnumerator loadLevel() { yield return(null); #if UNITY_ANDROID && !UNITY_EDITOR // yield return new WaitForSeconds(0.5f); if (Application.platform == RuntimePlatform.Android) { // string mainPath; // do // { // yield return new WaitForSeconds(0.5f); // mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); // log("waiting mainPath => " + mainPath); // } // while( mainPath == null); string mainPath = null; yield return(new WaitForSeconds(0.5f)); mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); if (mainPath != null) { if (downloadStarted == false) { downloadStarted = true; string uri = "file://" + mainPath; log("downloading " + uri); WWW www = WWW.LoadFromCacheOrDownload(uri, 0); // Wait for download to complete yield return(www); if (www.error != null) { log("wwww error " + www.error); } else { Application.LoadLevel(nextScene); } } } else { Application.LoadLevel(nextScene); } } #else Application.LoadLevel(nextScene); #endif }
private IEnumerator WaitForObb() { // native UI will show progress bar while (isDownloadingObb && GooglePlayDownloader.GetMainOBBPath(expansionFilePath) == null) { yield return(new WaitForSeconds(0.5f)); } isDownloadingObb = false; OnObbComplete(true); }
void OnGUI() { #if UNITY_ANDROID if (!GooglePlayDownloader.RunningOnAndroid()) { GUI.Label(new Rect(10, 10, Screen.width - 10, 40), "Use GooglePlayDownloader only on Android device!"); return; } string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { GUI.Label(new Rect(10, 10, Screen.width - 10, 40), "External storage is not available!"); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); // must be called before calling FetchOBB. string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); GUI.Label(new Rect(10, 10, Screen.width - 10, 40), "Main: " + (mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length))); GUI.Label(new Rect(10, 55, Screen.width - 10, 40), "Patch: " + (patchPath == null ? " NOT AVAILABLE" : patchPath.Substring(expPath.Length))); // GooglePlayDownloader.FetchOBB(); // fetchingStarted = true; // StartCoroutine(Load()); if (mainPath == null || patchPath == null) { if (GUI.Button(new Rect(10, 100, 150, 150), "Fetch OBBs")) { GooglePlayDownloader.FetchOBB(); fetchingStarted = true; StartCoroutine(Load()); Debug.Log("Started from button pressed"); } } else { GooglePlayDownloader.FetchOBB(); fetchingStarted = true; StartCoroutine(Load()); Debug.Log("Started from paths being set"); } } #endif }
public void Start() { GooglePlayDownloader.Init(PublicKeyFromGooglePlay); if (GooglePlayDownloader.RunningOnAndroid()) { string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath != null) { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); if (mainPath == null) { GooglePlayDownloader.DeleteAllOldOBBs(expPath); GooglePlayDownloader.FetchOBB(); } } } }
void OnGUI() { GUI.skin = mySkin; GUI.DrawTexture(new Rect(0, 0, background.width, background.height), background); if (!GooglePlayDownloader.RunningOnAndroid()) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "Use GooglePlayDownloader only on Android device!"); return; } expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "External storage is not available!"); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); if (alreadyLogged == false) { alreadyLogged = true; Debug.Log("expPath = " + expPath); Debug.Log("Main = " + mainPath); Debug.Log("Main = " + mainPath.Substring(expPath.Length)); if (mainPath != null) { StartCoroutine(loadLevel()); } } if (mainPath == null) { GUI.Label(new Rect(Screen.width - 600, Screen.height - 230, 430, 60), "There seems ato be Problem while Downloading Files Click on Fetch File to do it Mannually"); if (GUI.Button(new Rect(10, 100, 100, 100), "Fetch Files")) { GooglePlayDownloader.FetchOBB(); StartCoroutine(loadLevel()); } } } }
void LoadResource() { Debug.Log("LoadResource"); if (!GooglePlayDownloader.RunningOnAndroid()) { //GUI.Label(new Rect(10, 10, Screen.width-10, 20), "Use GooglePlayDownloader only on Android device!"); Debug.Log("Use GooglePlayDownloader only on Android device!"); return; } string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { //GUI.Label(new Rect(10, 10, Screen.width-10, 20), "External storage is not available!"); Debug.Log("External storage is not available!"); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); Debug.Log("mainPath:" + mainPath); Debug.Log("patchPath:" + patchPath); //GUI.Label(new Rect(10, 10, Screen.width-10, 20), "Main = ..." + ( mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length))); //GUI.Label(new Rect(10, 25, Screen.width-10, 20), "Patch = ..." + (patchPath == null ? " NOT AVAILABLE" : patchPath.Substring(expPath.Length))); if (mainPath == null) //if (GUI.Button(new Rect(10, 100, 100, 100), "Fetch OBBs")) { GooglePlayDownloader.SetMainOBBInfo(ClientConfigure.getResourceURL()); //GooglePlayDownloader.SetMainOBBFileName("file name"); GooglePlayDownloader.FetchOBB(); StartCoroutine(WaitForObbDownLoadOver()); } else { //SDKManager.GetInstance(); Application.LoadLevel(Utils.UI_NAME_Login); } } }
public void Init() { #if !RC_BUILD || SKU_CHINA OnObbComplete(true); return; #else // see if obb is already downloaded expansionFilePath = GooglePlayDownloader.GetExpansionFilePath(); if (GooglePlayDownloader.GetMainOBBPath(expansionFilePath) != null) { OnObbComplete(true); } else { Log.Debug("expansionFilePath = " + expansionFilePath); isDownloadingObb = true; GooglePlayDownloader.FetchOBB(); StartCoroutine(WaitForObb()); } #endif }
// void OnGUI() // { // GUI.skin = mySkin; // GUI.DrawTexture(new Rect(0,0,background.width,background.height),background); // // if (!GooglePlayDownloader.RunningOnAndroid()) // { // GUI.Label(new Rect(10, 10, Screen.width-10, 20), "Use GooglePlayDownloader only on Android device!"); // return; // } // // expPath = GooglePlayDownloader.GetExpansionFilePath(); // if (expPath == null) // { // GUI.Label(new Rect(10, 10, Screen.width-10, 20), "External storage is not available!"); // } // else // { // string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); // string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); // if( alreadyLogged == false ) // { // alreadyLogged = true; // log( "expPath = " + expPath ); // log( "Main = " + mainPath ); // log( "Main = " + mainPath.Substring(expPath.Length)); // // if (mainPath != null) // StartCoroutine(loadLevel()); // // } // //GUI.Label(new Rect(10, 10, Screen.width-10, Screen.height-10), logtxt ); // // if (mainPath == null) // { // GUI.Label(new Rect(Screen.width-600, Screen.height-230, 430, 60), "The game needs to download 200MB of game content. It's recommanded to use WIFI connexion."); // if (GUI.Button(new Rect(Screen.width-500, Screen.height-170, 250, 60), "Start Download !")) // { // GooglePlayDownloader.FetchOBB(); // StartCoroutine(loadLevel()); // } // } // // } // // } void Start() { // nextScene = ""; #if UNITY_ANDROID && !UNITY_EDITOR if (Application.platform == RuntimePlatform.Android) { // log ("start => "); // expPath = GooglePlayDownloader.GetExpansionFilePath(); // log ("expPath => " + expPath); // string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); // log ("mainPath => " + mainPath); // string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); // log ("patchPath => " + patchPath); // if (mainPath != null) // StartCoroutine(loadLevel()); GooglePlayDownloader.SetPublicKey(PUBLIC_KEY); expPath = GooglePlayDownloader.GetExpansionFilePath(); } #endif StartCoroutine(loadLevel()); }
void Start() { #if !UNITY_EDITOR && UNITY_ANDROID string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { Debug.LogWarning("External storage is not available!"); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); Debug.LogWarning("Main = ..." + (mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length))); Debug.LogWarning("Patch = ..." + (patchPath == null ? " NOT AVAILABLE" : patchPath.Substring(expPath.Length))); if (mainPath == null || patchPath == null) { GooglePlayDownloader.FetchOBB(); } } #endif }
IEnumerator DoCheck() { Error = string.Empty; IsMounted = false; Notify(Localizer.GetString("ID_SPARX_CONTENT_CHECKING")); yield return(null); if (!GooglePlayDownloader.RunningOnAndroid()) { yield break; } string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (string.IsNullOrEmpty(expPath)) { Error = "ID_SPARX_OBB_ERROR"; yield break; } EB.Debug.Log("Ext Folder: " + expPath); string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); if (string.IsNullOrEmpty(mainPath)) { // moko: verify we have enough disk-space for the OBB at the destinated OBB path var size = EB.FileSystem.GetAvailableSpaceInBytes(expPath); if (size > this.ExpectedObbSize) { EB.Debug.Log("ObbManager > disk space availbity: " + expPath + ", size: " + size + "/" + this.ExpectedObbSize); } else { EB.Debug.LogError("ObbManager > Not Enough disk space: " + expPath + ", size: " + size + "/" + this.ExpectedObbSize); Error = "ID_SPARX_CONTENT_FAILED_EXTRACT"; yield break; } EB.Debug.Log("Fetching main OBB "); GooglePlayDownloader.FetchOBB(); yield return(new WaitForSeconds(3.0f)); } mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); EB.Debug.Log("Main OBB Path: " + mainPath); if (string.IsNullOrEmpty(mainPath)) { EB.Debug.Log("Failed to download OBB"); Error = "ID_SPARX_CONTENT_FAILED"; yield break; } // cleanup old content folder try { if (Directory.Exists(BasePath)) { Directory.Delete(BasePath, true); } } catch { } IsMounted = true; EB.Debug.Log("Main Path: " + mainPath); Loader.OverridePath("jar:file://" + mainPath + "!/"); }
private bool hasOBB() { mainExpansionPath = GooglePlayDownloader.GetMainOBBPath(expansionPath); return(mainExpansionPath != null); }
//============================================================================= void OnGUI() { #if UNITY_ANDROID #if ANDROID_GOOGLE if (!isOkToLoadLevel) { if (!GooglePlayDownloader.RunningOnAndroid()) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "Use GooglePlayDownloader only on Android device!"); return; } string expPath = GooglePlayDownloader.GetExpansionFilePath(); if (expPath == null) { GUI.Label(new Rect(10, 10, Screen.width - 10, 20), "External storage is not available!"); } else { string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath); //string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath); if (mainPath == null) // || patchPath == null) { if (!isFetchingOBBs) { Debug.Log("Main = ..." + (mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length))); //Debug.Log("Patch = ..." + (patchPath == null ? " NOT AVAILABLE" : patchPath.Substring(expPath.Length))); Debug.Log("Fetching OBB ..."); //Camera.main.backgroundColor = new Color( 0.0f , 0.0f , 0.0f , 1.0f ); //Camera.main.clearFlags = CameraClearFlags.SolidColor; GooglePlayDownloader.FetchOBB(); isFetchingOBBs = true; } } else { Debug.Log("Main = ..." + (mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length))); //Debug.Log("Patch = ..." + (patchPath == null ? " NOT AVAILABLE" : patchPath.Substring(expPath.Length))); isOkToLoadLevel = true; } } } #else isOkToLoadLevel = true; #endif #else isOkToLoadLevel = true; #endif if (isOkToLoadLevel && !isLoadingLevel) { if ((string.Empty != Application.dataPath) && ("" != Application.dataPath)) { Debug.Log(Application.dataPath); Debug.Log("Loading level: OpeningCreditsRoom"); Application.LoadLevel("OpeningCreditsRoom"); //isLoadingLevel = true; //DummyActivity(); } else { Debug.Log("App datapath is empty!"); } isLoadingLevel = true; } }