public string fileName_1;
public Sprite[] LoadSprite(string name)
{
fileName_1 = Path.Combine(Application.streamingAssetsPath, name);
Debug.Log(fileName_1);
if (!Directory.Exists(fileName_1))
{
throw new FileNotFoundException("Could not find file: " + fileName_1);
}
string[] strings = Directory.GetFiles(fileName_1, "*.png", SearchOption.AllDirectories);
Sprite[] sprites = new Sprite[strings.Length];
for (int i = 0; i < strings.Length; i++)
{
byte[] bytes = File.ReadAllBytes(strings[i]);
Texture2D texture = new Texture2D(2, 2);
texture.LoadImage(bytes);
sprites[i] = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
}
return sprites;
}
06-20
2011
05-08
05-08
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交