Hello Guest

Author Topic: Hide or Show Sprite with Script  (Read 4165 times)

hairyconiption

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Hide or Show Sprite with Script
« 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 ??

}

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Hide or Show Sprite with Script
« Reply #1 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
}