Rav*_*viG 3 unity-game-engine unity5
如何从资源文件夹加载图像并将该图像设置为UI Image的源图像?
将精灵放在任何以资源开头的文件夹中,例如我的精灵在"资源/图像/测试"中
[SerializeField] private UnityEngine.UI.Image image = null;
private void Awake()
{
if( image != null )
{
image.sprite = Resources.Load<Sprite>( "Images/test" );
}
}
Run Code Online (Sandbox Code Playgroud)
http://docs.unity3d.com/462/Documentation/ScriptReference/UI.RawImage.html http://docs.unity3d.com/ScriptReference/Resources.Load.html