Author Topic: Changing texture of sprite at runtime  (Read 3534 times)

eventropy

  • Guest
Changing texture of sprite at runtime
« on: August 31, 2013, 05:45:41 PM »
I want to apply a mouse over effect that changes the background texture of a UISprite, how would I go about this?

LightSky

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 56
    • View Profile
Re: Changing texture of sprite at runtime
« Reply #1 on: August 31, 2013, 06:07:50 PM »
public UISprite YourSprite;

void OnHover (bool isOver)  //Is called on any widget when you hover the cursor over it
{
    if(isOver) //If cursor is hovering
    {
       YourSprite.spriteName = "String name of your sprite in the same atlas" 
    }
    else
    {
       YourSprite.spriteName = "Previous name" 
    }
}

If you need to change the atlas just call  YourSprite.atlas and set it to whatever atlas you need.