您的位置:首页 > 移动开发 > Unity3D

Unity3D-动态加载资源

2015-11-11 22:59 387 查看
一、内部调用

1.Resources.Load("path","type");或Resources.LoadAll("path","type");

加载储存在Resources文件夹中path处的资源,必须忽略后缀名。

GameObject instance = Instantiate(Resources.Load("enemy", typeof(GameObject)));


2.Resources.LoadAssetAtPath("assetPath","type");

返回所在资源路径上的一个资源(编辑器仅仅)。

注意:所有资源名字和路径在Unity是带有正斜杠,如果在路径中使用反斜杠,将获得错误。

prefab = Resources.LoadAssetAtPath("Assets/Artwork/mymodel.fbx", typeof(GameObject));


二、外部调用

1.Assetbundle
http://blog.csdn.net/wsc122181582/article/details/50731897
2.WWW

public string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
IEnumerator Start() {
WWW www = new WWW(url);
yield return www;
Renderer renderer = GetComponent<Renderer>();
renderer.material.mainTexture = www.texture;
}

注意:

1.地址注意回避%符号

2.支持http://, https://, file://, ftp:// 等协议
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: