2D Toolkit Forum

2D Toolkit => Support => Topic started by: Euthyphro on December 11, 2014, 09:18:58 pm

Title: spriteDefinitions has empty values in it?
Post by: Euthyphro on December 11, 2014, 09:18:58 pm
The sprites on one of my sprite sheets randomly come out like this image rather than the actual sprite:
(http://i.imgur.com/n8qz9hb.jpg)

This doesn't happen every time. I'm trying to pull out a random sprite with the following code added to t2dSpriteCollectionData which returns "blank" values:

Code: [Select]
public string GetRandomSpriteName()
{
return spriteDefinitions[Random.Range(0, spriteDefinitions.Length)].name;
}

Any suggestions on why this would return a value most of the time but the odd time it is an empty string? In the collection, every sprite has a name and yet this sometimes returns an empty string.
Title: Re: spriteDefinitions has empty values in it?
Post by: unikronsoftware on December 12, 2014, 03:10:03 pm
Deleted sprites are not removed from the list, just replaced with an empty one. You will need to run through the list and find Valid ones.