- Home /
Question by
ndrummer31 · Jan 18, 2015 at 10:18 PM ·
spritesresources.loadspritesheetdirectory
How to access a child sprite of a sprite sheet from a directory?
I would like to set an icon to an item from code. Here's what I have thus far:
public enum ItemType { Item, Tool, Weapon, Block, }
public string itemName;
public int itemID;
public string itemDesc;
public int itemDurability;
public Sprite itemIcon;
public int itemAttackPower;
public ItemType itemType;
#region Constructors
public Item ( string name, int id, ItemType type )
{
itemName = name;
itemID = id;
itemType = type;
itemIcon = Resources.Load<Sprite> ( "ItemIcons/" + name );
}
The name of the icon file resides in the resources folder with a file name of that of its item. It is, however in a sprite sheet (named "Icons") so my question is: How do I access the file from a directory? (as asked in the title.)
I'm a novice programmer so any advice would be greatly appreciated! :)
Thanks!
Comment