Hello Guest

Author Topic: spriteDefinitions has empty values in it?  (Read 3085 times)

Euthyphro

  • Newbie
  • *
  • Posts: 20
    • View Profile
spriteDefinitions has empty values in it?
« 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:


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.
« Last Edit: December 11, 2014, 10:08:06 pm by Euthyphro »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: spriteDefinitions has empty values in it?
« Reply #1 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.