// Use this for initialization IEnumerator Start() { // GameObject loadingEffect =GameObject.Instantiate(AssetDataDase.LoadAssetAtPath("Assets/Prefabs/myPrefab.prefab", typeof(GameObject)) as GameObject; //GameObject textObject = (GameObject)Instantiate(Resources.Load("RichTextUi_1")); // GameObject instance = Instantiate(Resources.Load("RichTextUi_1", typeof(GameObject))) as GameObject; if (assetBundleName == null || assetBundleName == "") { //assetBundleName = "test_book"; assetBundleName = "solar_system_book"; } yield return(AssetBundleHelper.getInstance().InitializeAssetBunder(assetBundleName)); try { //DebugOnScreen.Log("BookLoader Start assetBundleName=" + assetBundleName); BookSceneLoader sceneLoader = gameObject.AddComponent <BookSceneLoader>(); sceneLoader.assetBundleName = assetBundleName; sceneLoader.sceneName = "page1"; } catch (System.Exception ex) { DebugOnScreen.Log(ex.ToString()); } }
protected IEnumerator loadSceneMetaData(string jsonFileName) { if (!loadedSceneInfo.ContainsKey(jsonFileName)) { yield return(AssetBundleHelper.getInstance().LoadAsset <TextAsset>(metadataAssetBundleName, jsonFileName, textAssetLoaded => { if (Debug.isDebugBuild) { Debug.Log("json string= " + textAssetLoaded.text); } currentScene = JsonUtility.FromJson <SceneInfo>(textAssetLoaded.text); loadedSceneInfo.Add(jsonFileName, currentScene); if (Debug.isDebugBuild) { Debug.Log("Finished loading currentScene name= " + currentScene.name + ", title=" + currentScene.title + ", info= " + currentScene.info); } })); } else { currentScene = loadedSceneInfo[jsonFileName]; if (Debug.isDebugBuild) { Debug.Log("Loaded from catch currentScene name= " + currentScene.name + ", title=" + currentScene.title + ", info= " + currentScene.info); } } yield return(StartCoroutine(LoadScence(currentScene))); }
// Use this for initialization IEnumerator Start() { if (Debug.isDebugBuild) { Debug.Log("BookLoaderScript Start assetBundleName=" + assetBundleName); } uiEventHandler = gameObject.GetComponent <UiEventHandler>(); if (assetBundleName == null || assetBundleName == "") { //assetBundleName = "test_book"; assetBundleName = "solar_system_book"; } metadataAssetBundleName = assetBundleName + ".metadata"; // Add DisplayTextUiController displayTextUiController = gameObject.AddComponent <DisplayTextUiController>(); displayTextUiController.mainCanvas = mainCanvas; displayTextUiController.metadataAssetBundleName = metadataAssetBundleName; //end //DontDestroyOnLoad(gameObject); yield return(StartCoroutine(AssetBundleHelper.getInstance().InitializeAssetBunder(assetBundleName))); yield return(StartCoroutine(loadAssetBundleMetaData())); string jsonFileName = jsonSceneDataFileName + currentSceneIdx.ToString(); yield return(StartCoroutine(loadSceneMetaData(jsonFileName))); //SceneInfo sceneInfo = new SceneInfo(); //sceneInfo.name = "page1"; // yield return StartCoroutine(LoadScence(sceneInfo)); // Load level. //yield return StartCoroutine(InitializeLevelAsync("page1", true)); }
// Use this for initialization IEnumerator Start() { GlobalVar.shareContext.loadingIndicator.SetActive(true); yield return(AssetBundleHelper.getInstance().LoadScene(assetBundleName, sceneName, true)); DestroyObject(this); GlobalVar.shareContext.loadingIndicator.SetActive(false); }
void OnDestroy() { if (Debug.isDebugBuild) { Debug.Log("BookLoaderScript was destroyed <===================="); } AssetBundleHelper.getInstance().unLoadAssetBundleManager(); loadedSceneInfo.Clear(); }
// Use this for initialization IEnumerator Start() { Debug.Log("RUN PLATFORM WEBGL 1"); // GameObject loadingEffect =GameObject.Instantiate(AssetDataDase.LoadAssetAtPath("Assets/Prefabs/myPrefab.prefab", typeof(GameObject)) as GameObject; //GameObject textObject = (GameObject)Instantiate(Resources.Load("RichTextUi_1")); // GameObject instance = Instantiate(Resources.Load("RichTextUi_1", typeof(GameObject))) as GameObject; //Caching.CleanCache(); if (assetBundleName == null || assetBundleName == "") { //assetBundleName = "test_book"; assetBundleName = "solar_system_book"; } #if !UNITY_WEBGL // DebugOnScreen.Log("init mainfest 10"); yield return(AssetBundleHelper.getInstance().InitializeAssetBunder(assetBundleName)); try { //DebugOnScreen.Log("BookLoader Start assetBundleName=" + assetBundleName); BookSceneLoader sceneLoader = gameObject.AddComponent <BookSceneLoader>(); sceneLoader.assetBundleName = assetBundleName; sceneLoader.sceneName = "page1"; } catch (System.Exception ex) { DebugOnScreen.Log(ex.ToString()); } #else /* * * homeButton.SetActive(false); * string url = Application.absoluteURL; * Dictionary<string, string> httpGetData=null; * if(url != null) * { * httpGetData = parseHttpGetData(url); * } * string assetBundleUrl = "vn/books/science/230002_solar_system_book/"; * assetBundleName = "solar_system_book"; * DebugOnScreen.Log("assetBundleUrl: " + assetBundleUrl); * if (httpGetData!=null && httpGetData.ContainsKey("assetBundleName")&& httpGetData.ContainsKey("assetBundleUrl")) * { * * assetBundleName = httpGetData["assetBundleName"]; * assetBundleUrl = httpGetData["assetBundleUrl"]; * DebugOnScreen.Log("getted assetBundleName=" + assetBundleName+ ", assetBundleUrl=" + assetBundleUrl); * } * yield return AssetBundleHelper.getInstance().InitializeAssetBunderWebGL(assetBundleName, assetBundleUrl); */ //DebugOnScreen.Log("RUN PLATFORM WEBGL 5"); Debug.Log("RUN PLATFORM WEBGL 2"); yield return(null); #endif }
protected IEnumerator loadAssetBundleMetaData() { yield return(AssetBundleHelper.getInstance().LoadAsset <TextAsset>(metadataAssetBundleName, jsonAssetBundleMetaDataFileName, textAssetLoaded => { assetBundleInfo = JsonUtility.FromJson <AssetBundleInfo>(textAssetLoaded.text); string dependenciesAsset = ""; foreach (string depend in assetBundleInfo.dependenciesAsset) { dependenciesAsset += depend + " "; } if (Debug.isDebugBuild) { Debug.Log("Finished loading assetBundleInfo title=" + assetBundleInfo.title + ", totalScenes" + assetBundleInfo.totalScenes + dependenciesAsset + ", dependenciesAsset=" + dependenciesAsset); } })); }
IEnumerator loadBook(ParameterFormJson json) { yield return(AssetBundleHelper.getInstance().InitializeAssetBunderWebGL(json.assetBundleName, json.assetBundleUrl)); try { DebugOnScreen.Log("BookLoader Start assetBundleName=" + assetBundleName); BookSceneLoader sceneLoader = gameObject.AddComponent <BookSceneLoader>(); sceneLoader.assetBundleName = json.assetBundleName; sceneLoader.sceneName = "page1"; } catch (System.Exception ex) { DebugOnScreen.Log(ex.ToString()); } }
private IEnumerator loadTextToUi(GameObject uiGameobject, TextContent textContent) { uiGameobject.SetActive(true); string text = null; if (loadedTexfile.ContainsKey(textContent.textFile)) { if (Debug.isDebugBuild) { Debug.Log("[DisplayTextUiController-loadTextToUi] load text from cache."); } text = loadedTexfile[textContent.textFile]; } else { yield return(AssetBundleHelper.getInstance().LoadAsset <TextAsset>(metadataAssetBundleName, textContent.textFile, textAssetLoaded => { text = textAssetLoaded.text; loadedTexfile.Add(textContent.textFile, text); })); } // Text txtTile = uiGameobject.transform.Find("Object").Find("titleBox").Find("txt_title").gameObject.GetComponent<Text>(); // Text txtTile = uiGameobject.GetComponentInChildren<Text>(); Text[] textUis = uiGameobject.GetComponentsInChildren <Text>(); foreach (Text textUi in textUis) { if (textUi.gameObject.name == NAME_TEXT_TITLE) { textUi.text = currentManinObject.Title; } else if (textUi.gameObject.name == NAME_TEXT_HEADER) { textUi.text = textContent.header; } else if (textUi.gameObject.name == NAME_TEXT_BODY) { textUi.text = text; } } forceScrollTop(uiGameobject); }
protected IEnumerator LoadScence(SceneInfo sceneInfo) { displayTextUiController.onChangeScene(); LoadingEffect loadingEffect = gLoadingEffect.GetComponent <LoadingEffect>(); loadingEffect.loading = true; uiEventHandler.onSceneChange(currentSceneIdx, assetBundleInfo.totalScenes); float startTime = Time.realtimeSinceStartup; // Load level from assetBundle. yield return(AssetBundleHelper.getInstance().LoadScene(assetBundleName, sceneInfo.name, true)); uiEventHandler.OndoneLoadScene(); // Calculate and display the elapsed time. float elapsedTime = Time.realtimeSinceStartup - startTime; if (Debug.isDebugBuild) { Debug.Log("Finished loading scene: " + sceneInfo.name + " in " + elapsedTime + " seconds"); } interactiveProcessing(sceneInfo); loadingEffect.loading = false; //gLoadingEffect.GetComponent<Renderer>().enabled = false; }
public IEnumerator showTextUi(MainObject mainObject, bool hideOnTouchNothing, System.Action explorerButtonClick) { if (currentManinObject != null && currentManinObject.Equals(mainObject) && currentTextUIGameObject.activeSelf) { if (Debug.isDebugBuild) { Debug.Log("[DisplayTextUiController-showTextUi] show text already!"); } hideTextUi(); yield break; } currentManinObject = mainObject; this.hideOnTouchNothing = hideOnTouchNothing; TextContent textContent = mainObject.texts[mainObject.currentTextIndex]; GameObject uiGameobject = null; string textui = textContent.displayUI; if (loadedPrefab.ContainsKey(textui)) { if (Debug.isDebugBuild) { Debug.Log("[DisplayTextUiController-showTextUi] Got uiGameobject from cache!"); } uiGameobject = loadedPrefab[textui]; } else { if (Debug.isDebugBuild) { Debug.Log("[DisplayTextUiController-showTextUi] Load uiGameobject from assetBundle!"); } GameObject prefab = null; string[] assetBundleMetaData = textui.Split(new string[] { "/" }, System.StringSplitOptions.RemoveEmptyEntries); string commonAssetBundleName = assetBundleMetaData[0]; string assetName = assetBundleMetaData[1]; yield return(AssetBundleHelper.getInstance().LoadAsset <GameObject>(commonAssetBundleName, assetName, prefabLoaded => { prefab = prefabLoaded; })); if (prefab != null) { uiGameobject = (GameObject)GameObject.Instantiate(prefab, mainCanvas.transform, false); loadedPrefab.Add(textui, uiGameobject); } AddEventTriggerToButtons(uiGameobject); } if (uiGameobject != null) { currentTextUIGameObject = uiGameobject; // now we add eventtrigger for explorerButton AddEventTrigeerToExplorerButton(uiGameobject, explorerButtonClick); yield return(loadTextToUi(uiGameobject, textContent)); if (Camera.main.GetComponent <CameraController_1>()) { Camera.main.GetComponent <CameraController_1> ().OnShowUi(); } } }