Author Topic: Hiding sprites without active = false  (Read 5808 times)

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Hiding sprites without active = false
« on: November 19, 2014, 07:11:17 AM »
Using
  1. gameObject.SetActive (false);
  2. NGUITools.SetActive(gameObject, false);
hides an object but also disables certain methods.
If I just want to hide it, what should I do?
In pure Unity
  1. gameObject.renderer.enabled = false works
With NGUI UISprite, what should I do? Maybe
  1. gameObject.GetComponent<UISprite>().enabled = false
too?
Game developer on Casual Arena.

RobBrooks

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Hiding sprites without active = false
« Reply #1 on: November 19, 2014, 07:26:16 AM »
Does disabling the UISprite component give you what you need?

I'm guessing it probably does.

So why the doubt?  ;)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Hiding sprites without active = false
« Reply #2 on: November 19, 2014, 03:52:59 PM »
sprite.enabled = false is just fine. sprite.alpha = 0f; would be an alternative.

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Re: Hiding sprites without active = false
« Reply #3 on: November 21, 2014, 01:06:56 PM »
Does disabling the UISprite component give you what you need?

I'm guessing it probably does.

So why the doubt?  ;)
Something working doesn't imply it is fully correct. I considered important to have an opinion about that.
For example, i'm seeing that maybe I should disable the Circle or Box Collider, since I could be receiving click events on the colliders. So, in general I wanted to ask ArenMook about the components I should enable/disable.

sprite.enabled = false is just fine. sprite.alpha = 0f; would be an alternative.
Shold I disable also the colliders?

Thank you.
Game developer on Casual Arena.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Hiding sprites without active = false
« Reply #4 on: November 21, 2014, 09:03:59 PM »
Setting sprite alpha to 0 automatically makes the collider be ignored.