2D Toolkit Forum

2D Toolkit => Support => Topic started by: hairyconiption on April 29, 2014, 11:25:13 pm

Title: Hide or Show Sprite with Script
Post by: hairyconiption on April 29, 2014, 11:25:13 pm
I am brand new to 2D Toolkit, so here goes!   I need to hide/show a sprite based on info in my script. Specifically star ratings for levels, so I have some code that goes like this

If (star1){
?? Show Star1 image ??

}
Title: Re: Hide or Show Sprite with Script
Post by: unikronsoftware on April 30, 2014, 05:16:32 pm
Hi, you do that the same way you show/hide anything in Unity. You will need a reference to your gameobject, and once you have that you can simply gameObejct.SetActive(false) to hide it.

GameObject star1; // drag a reference to star1 here

if (...) {
   star1.SetActive(false); // to hide it
}