playMaker

Author Topic: Sub objects hide when main object is not active NGUI  (Read 6409 times)

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Sub objects hide when main object is not active NGUI
« on: March 16, 2013, 05:20:37 PM »
Hello everyone.

I will try and write this question clearly but if it isn't please feel free to ask questions. I am using NGUI

What I have is a little popup menu that I have made from a sprite. Inside this sprite (which is essentially a background image for a menu) I have 6 different buttons. However when the menu sprite is not active the buttons are still visible. How do I go about having these buttons only show when the menu is shown? I don't want to simply deactivate the buttons as there functions require them to be active.

To understand better...

What I am trying to do is a have a button that open up a menu that allows a player to send items to another player.

Then there is a second button that allows you to see the items that you have been sent.

Hope there is enough information here and that I have written the question clearly.

Looking forward to hearing your responses

All the best

WB
« Last Edit: March 16, 2013, 05:33:59 PM by will_brett »

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Sub objects hide when main object is not active NGUI
« Reply #1 on: March 16, 2013, 06:18:53 PM »
I don't quite understand.
You say:

Quote
How do I go about having these buttons only show when the menu is shown?

You want them to show only then, when the actual menu is shown.

But then you say:

Quote
I don't want to simply deactivate the buttons as there functions require them to be active.

I don't get this. If the buttons are not shown, how can the Player access those functions?

If i get this right, you have this scenario:

- One Button, when it is clicked/tapped, the Menu shows up
-> that Menu has its own 6 buttons

If i am right, i don't see a problem (de)activating the Buttons.

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Sub objects hide when main object is not active NGUI
« Reply #2 on: March 16, 2013, 06:36:34 PM »
Thanks for reply.

The issue is that these buttons are activated by another player.

Perhaps it would make more sense if i say that the buttons represent items that another player has sent. I dont want these items to just appear on the screen... i want them to appear inside the menu to keep everything tidy. The other player may send these items when the menu isn't open.

hope this makes more sense

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Sub objects hide when main object is not active NGUI
« Reply #3 on: March 16, 2013, 06:49:29 PM »
Ah, now i understand.

So, when you press the First Button you get the Menu with the Items (aka Buttons), which another Player sent.
Can't you just make these Items/Buttons invisible. They stay active, but as soon the Menu pops out, you make them visible again.

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Sub objects hide when main object is not active NGUI
« Reply #4 on: March 16, 2013, 07:28:08 PM »
how is this done? I didn't even realise this was an option

Cheers

Will

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Sub objects hide when main object is not active NGUI
« Reply #5 on: March 16, 2013, 07:39:53 PM »
Im using NGUI btw and im not sure you can just set the renderer.enabled = false like you can with objects

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Sub objects hide when main object is not active NGUI
« Reply #6 on: March 16, 2013, 08:22:09 PM »
You can access it via "Set Property".

There you drag and drop the NGUI-Component (the UISprite component), and be sure that you dragged and dropped that certain Component into the "Target Field" of the "Set Property"-Action. Here is a screen:



(In this case the "Background" is the GameObject, but you have to drag the "UISliced Sprite"-Component in the Target-Field!)

Just uncheck the "enabled"-Property and there you go.
I do not know if this is really the best approach within NGUI, i use it and for now it works fine for me.

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Sub objects hide when main object is not active NGUI
« Reply #7 on: March 17, 2013, 08:53:50 AM »
Brilliant I will try that today.

Thank you

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Sub objects hide when main object is not active NGUI
« Reply #8 on: March 17, 2013, 09:11:48 AM »
Just gave this a go. It sort of works but it actually just does the same thing as activate game object.

The issue is that I want the button/sprite to only be seen when the menu is open (this bit works fine) but in the menu I want it to be hidden unless the other player has sent it.

What Im getting at the moment is that the button is there regardless of wether or not the other player has sent the item.

cheers

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Sub objects hide when main object is not active NGUI
« Reply #9 on: March 17, 2013, 11:17:03 AM »
Ok so what I am currently working on is an FSM that checks to see if the menu is open or not. If it is and the other player has sent the item then it will appear. My only issue now is that if the other player sends an item and the receiving player clicks the menu the item appears but if they close the menu without clicking the tem the item disappears.

Im sure I will be able to fix this soon

Thanks for all your help.