public void GoToAr() { ArAnimation.SetActive(true); ArSession.SetActive(true); if (Projects.Count != 0) { Input.text = Projects[projectIndex].url.Replace("\\", ""); LoadingPanal.SetActive(true); if (Projects[projectIndex].LoadedObj == null) { // LoadInSeen(); StartCoroutine(LoadObject(PlayerPrefs.GetString(Projects[projectIndex].name), "ar")); } else { PlaceOnPlane.AssatObj = Projects[projectIndex].LoadedObj; LoadingPanal.SetActive(false); // ARCanvas.SetActive(true); ProjectsPanal.SetActive(false); ArSession.SetActive(true); ArModePanel.SetActive(true); ArExitpanel.SetActive(true); } } else { PlaceOnPlane.AssatObj = DefaultObject; LoadingPanal.SetActive(false); // ARCanvas.SetActive(true); ProjectsPanal.SetActive(false); ArSession.SetActive(true); ArModePanel.SetActive(true); ArExitpanel.SetActive(true); } }
IEnumerator LoadObject(string path, string viewer) { AssetBundleCreateRequest bundle = AssetBundle.LoadFromFileAsync(path); yield return(bundle); AssetBundle myLoadedAssetBundle = bundle.assetBundle; if (myLoadedAssetBundle == null) { Debug.Log("Failed to load AssetBundle!"); yield break; } var names = myLoadedAssetBundle.GetAllAssetNames(); // AssetBundleRequest request = myLoadedAssetBundle.LoadAsset(); //yield return request; AssetBundleRequest objreq = myLoadedAssetBundle.LoadAssetAsync(names[0]); yield return(objreq); //obj.transform.position = new Vector3(0.08f, -2.345f, 297.54f); // obj.transform.Rotate(350.41f, 400f, 20f); // obj.transform.localScale = new Vector3(1.0518f, 0.998f, 1.1793f); if (viewer.Equals("model")) { LoadedModel = Instantiate((GameObject)objreq.asset, Model.transform); LoadedModel.transform.parent = Model.transform; LoadingPanal.SetActive(false); ProjectsPanal.SetActive(false); ModelPanel.SetActive(true); ModelView.SetActive(true); } else { if (PlaceOnPlane.AssatObj != null) { PlaceOnPlane.AssatObj = null; } PlaceOnPlane.AssatObj = (GameObject)objreq.asset; Projects[projectIndex].LoadedObj = (GameObject)objreq.asset; Projects[projectIndex].isloaded = true; LoadingPanal.SetActive(false); // ARCanvas.SetActive(true); ArSession.SetActive(true); ArModePanel.SetActive(true); ProjectsPanal.SetActive(false); ArExitpanel.SetActive(true); } myLoadedAssetBundle.Unload(false); }