##Resources类
使用Resources加载资源,资源一定要放到Resources文件夹下,支持名字和路径加载。
1.可以有多个Resources文件夹同时存在。
2.Resources下的资源在打包后是加密压缩状态,运行时不可修改。
3.加载方法 : Load<类型>(名称或路径),名称不需要加后缀。
##示例
public class TeachRes : MonoBehaviour {
void Start () {
//加载预制体,可以有路径
GameObject prefab = Resources.Load<GameObject>("Prefabs/UI/Cube");
GameObject.Instantiate(prefab);
//加载精灵
Sprite sprite = Resources.Load<Sprite>("SkyTileSprite");
GameObject go = new GameObject("sp");
go.AddComponent<SpriteRenderer>().sprite = sprite;
//加载Texture
Texture tex = Resources.Load<Texture>("SkyTileSprite");
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.GetComponent<MeshRenderer>().material.mainTexture = tex;
//加载Texture2D -> sprite
Texture2D tex2d = Resources.Load<Texture2D>("SkyTileSprite");
Sprite sp = Sprite.Create(tex2d