Unity加载AB包(从本地或服务器)

	void Start () {

        //AssetBundle ab= AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "prefabs"));
        //if (ab==null)
        //{
        //    return;
        //}
        //GameObject cube= ab.LoadAsset("Cube");
        //Instantiate(cube);
        StartCoroutine(Instiate());
    }

    IEnumerator Instiate()
    {
        string uri = "http://192.168.1.103:9090/1/prefabs";
        UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(uri,0);
        yield return request.SendWebRequest();

        AssetBundle ab = DownloadHandlerAssetBundle.GetContent(request);
        GameObject cube= ab.LoadAsset("Cube");
        Instantiate(cube);
    }

你可能感兴趣的:(Unity)