问题描述
Sprite SpriteModding(字符串路径)
{
byte[] bytes = File.ReadAllBytes(Application.dataPath + "/Resources/fgsoftwarestudio.png");
Texture2D texture = new Texture2D(512,512,TextureFormat.RGB24,false);
texture.filterMode = FilterMode.Trilinear;
texture.LoadImage(bytes);
Sprite sprite = Sprite.Create(texture,new Rect(0,512),new Vector2(0.5f,0.0f),1.0f);
sprite_bg.GetComponent<SpriteRenderer>().sprite = sprite;
return null;
}
我打开游戏,精灵不渲染
解决方法
如果您从资源文件夹加载文件,请尝试Resources.Load
此处的更多信息:Information about Resources folder