IEnumerator krish() { GameData gamedata = new GameData(); string contents = System.IO.File.ReadAllText(Application.persistentDataPath + "/data.json"); //string contents = System.IO.File.ReadAllText("C:/Users/vamsi_56ftbm4/OneDrive/Desktop/Challenge/Menu/data.json"); gamedata = JsonUtility.FromJson <GameData>(contents); //WWW www = new WWW("C:/Users/vamsi_56ftbm4/OneDrive/Desktop/arone/test/testbundl"); WWW www = new WWW(GetFileURL(GetAndroidInternalFilesDir() + "//" + gamedata.CardName + "//Menu//" + pat + "//objects//" + a.ToString() + "//sample1//testbundl")); string[] words; while (!www.isDone) { yield return(null); } AssetBundle testbundle = www.assetBundle; if (testbundle != null) { Debug.Log("hiis"); //t.text = "workdone"; string[] k = testbundle.AllAssetNames(); Debug.Log(k[0]); words = k[0].Split('/'); var ds = testbundle.LoadAsset(words[3].Split('.')[0]) as GameObject; ob = Instantiate(ds, new Vector3(0, 0, 0), Quaternion.identity); ob.transform.Rotate(0f, 0f, 0f); Debug.Log(words[3].Split('.')[0]); } testbundle.Unload(false); }
void TestUI() { TestCheckAssetBundleManifest(); string[] dependencies = testManifest.GetAllDependencies(assetbundleTestUI); Dictionary <UnityEngine.Object, string> abObjectDict = new Dictionary <UnityEngine.Object, string>(); for (int i = 0; i < dependencies.Length; i++) { string path = assetbundleRoot + "/" + dependencies[i]; Debug.Log("依赖:" + path); AssetBundle ab = AssetBundle.LoadFromFile(path); if (ab != null) { testAssetBundleList.Add(ab); string[] names = ab.AllAssetNames(); foreach (string name in names) { UnityEngine.Object o = ab.LoadAsset <UnityEngine.Object>(name); if (o != null) { abObjectDict.Add(o, name); } } } else { Debug.LogError("不存在:" + path); } } GameObject canvas = GameObject.Find("Canvas"); Transform canvasTransform = canvas != null ? canvas.transform : null; string abpath = assetbundleRoot + "/" + assetbundleTestUI; testAssetBundle = AssetBundle.LoadFromFile(abpath); testAssetBundleList.Add(testAssetBundle); string[] assets = testAssetBundle.GetAllAssetNames(); for (int i = 0; i < assets.Length; i++) { string name = assets[i]; GameObject prefab = testAssetBundle.LoadAsset <GameObject>(name); if (prefab != null) { GameObject go = GameObject.Instantiate <GameObject>(prefab); if (canvasTransform != null) { go.transform.SetParent(canvasTransform, false); } Image[] images = go.GetComponentsInChildren <Image>(); for (int j = 0; j < images.Length; j++) { Image image = images[j]; if (image.sprite == null) { continue; } string p = abObjectDict[image.sprite]; Debug.LogFormat("{0} node:{1} name:{2} path:{3}", j, image.name, image.sprite.name, p); p = exportResources + "/" + p; if (File.Exists(p)) { image.sprite = AssetDatabase.LoadAssetAtPath <Sprite>(p); } else { Debug.LogError("不存在文件:" + p); } //Debug.LogFormat("{0} InstanceID:{1} HashCode:{2} node:{3} name:{4} path:{5}", j, image.sprite.GetInstanceID(), image.sprite.GetHashCode(), image.name, image.sprite.name, name); } } } }