/// <summary> /// 从本地加载AssetBundle资源 /// </summary> private void LoadLocalHostAssetBundle() { //AssetBundle.LoadFromFile(Application.persistentDataPath+"/"+"pl") AssetBundle ab1 = AssetBundle.LoadFromFile(Application.persistentDataPath + "/" + "player.unity3d"); AssetBundle ab2 = AssetBundle.LoadFromFile(Application.persistentDataPath + "/" + "shader.unity3d"); string[] materialArray = ab2.GetAllAssetNames(); Material material = null; foreach (var item in materialArray) { Debug.Log("tishi:" + Path.GetFileName(item)); if (Path.GetFileName(item) == "fenzi 1.mat") { Debug.Log(Path.GetFileName(item)); material = ab2.LoadAsset <Material>(Path.GetFileName(item)); Debug.Log("xianshi:" + Path.GetFileName(item)); } //Debug.Log(Path.GetFileName("材质球名称:" + item)); } string[] nameArray = ab1.GetAllAssetNames(); foreach (var item in nameArray) { Debug.Log("模型名称:" + Path.GetFileName(item)); GameObject obj = ab1.LoadAsset <GameObject>(Path.GetFileName(item)); GameObject go = GameObject.Instantiate(obj, Vector3.zero, Quaternion.identity); go.GetComponent <MeshRenderer>().material = material; if (go.name != "Directional Light(Clone)") { settingModle.GetModle(go); } go.transform.rotation = Quaternion.Euler(50, -30, 0); } //GameObject obj = ab1.LoadAsset<GameObject>("player"); //GameObject go = GameObject.Instantiate(obj, Vector3.zero, Quaternion.Euler(0, 180, 0)); //settingModle.GetModle(go); mainManager.uIManager.controlSlider.ChangeValue(0.1f); mainManager.uIManager.CloseLoadAssetBundlePanel(); mainManager.ChangeIsRecognition(); }