public Sprite LoadSourceSprite(string relativePath)
{
//Debug.Log("relativePath=" + relativePath);
//把资源加载到内存中
Object Preb = Resources.Load(relativePath, typeof(Sprite));
Sprite tmpsprite = null;
try
{
tmpsprite = Instantiate(Preb) as Sprite;
}
catch ( System.Exception ex )
{
}
//用加载得到的资源对象,实例化游戏对象,实现游戏物体的动态加载
return tmpsprite;
//return Resources.Load(relativePath, typeof(Sprite)) as Sprite;
}
Unity 从Resources中动态加载Sprite图片
最新推荐文章于 2025-06-17 13:36:36 发布