我的项目有多个精灵,位于 Assets\Sprites 中,我想使用 C# 脚本加载它们。
我已经测试过这个:
Sprite myFruit = Resources.Load <Sprite> ("Graphics_3");
But myFruit
仍然为空。
Resources.Load
将搜索目录Assets/Resources
.
如果你想把它放到Sprites
目录然后把它放进去Resources
(ex. Assets/Resources/Sprites
).
然后你可以像这样加载它:
Sprite myFruit = Resources.Load <Sprite> ("Sprites/Graphics_3");
还要确保您已在检查器中将图像类型设置为 Sprite。
如果你想加载多个精灵,请使用:
Sprite[] myFruit = Resources.LoadAll <Sprite> ("Sprites/Graphics_3");
See this http://answers.unity3d.com/questions/585927/unity-43-a-problem-with-loading-the-multiple-sprit.html更多细节。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)