首页 > 代码库 > unity学习 5.x解包

unity学习 5.x解包

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class bundleloadasset : MonoBehaviour {

// Use this for initialization
void Start () {
StartCoroutine(Load());
}

// Update is called once per frame
void Update () {

}
IEnumerator Load()
{
WWW www = new WWW("file:///D:/MyUnity/assetdatabase3d/Assets/Bundle/2000.assetbundle");
//网上加载资源:WWW www = new WWW("file:///" + Application.streamingAssetsPath + "2000.assetbundle");
yield return www;
AssetBundle bundle = www.assetBundle;
AssetBundleRequest request= bundle.LoadAssetAsync("Assets/New Material.mat", typeof(Material));
yield return request;
GameObject.Find("/Cube").GetComponent<Renderer>().material = request.asset as Material;

}
}

unity学习 5.x解包