LoadResources.cs 695 B

123456789101112131415161718192021
  1. using System.Collections;
  2. using UnityEngine;
  3. public class LoadResources : MonoBehaviour
  4. {
  5. // Start is called before the first frame update
  6. IEnumerator Start()
  7. {
  8. string path = "Assets/AssetsBundles/prefabs/Cube";
  9. AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(path);
  10. yield return request;//µÈ´ýÏìÓ¦
  11. AssetBundle ab = request.assetBundle;
  12. AssetBundleCreateRequest re = AssetBundle.LoadFromFileAsync("Assets/AssetsBundles/share");
  13. AssetBundle share = re.assetBundle;
  14. GameObject[] objs = ab.LoadAllAssets<GameObject>();
  15. foreach (var item in objs)
  16. {
  17. Instantiate(item);
  18. }
  19. }
  20. }