playMaker

Author Topic: NGUI Panel Management  (Read 3747 times)

rattlehead

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
NGUI Panel Management
« on: May 16, 2013, 01:23:25 AM »
Yesterday I purchased Playmaker and already did some little examples to get used to it. However, I actually got Playmaker to realize a sort of management system for GUI windows (I use NGUI).
A state represents one UIPanel and each button on this panel represents a transition to another panel. I already managed to change state by clicking on a button using the script in this forum. However, I don't know how to deactivate the the panel of the state I am leaving. Is this even possible with a FSM and Playmaker or is there an easy way around?

I'd really appreciate any help :-)

A3DStudio

  • Playmaker Newbie
  • *
  • Posts: 43
    • View Profile
    • A3DStudio
Re: NGUI Panel Management
« Reply #1 on: May 16, 2013, 02:04:22 AM »
Use the "Activate Game Object" action to deactivate a NGUI panel.
https://hutonggames.fogbugz.com/default.asp?W52

rattlehead

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: NGUI Panel Management
« Reply #2 on: May 16, 2013, 05:42:27 AM »
I know this action and I already wrote my own script using NGUITools.SetActive because this is more optimized to enable/disable panels.

But I don't know how to deactivate the panel on the state I am leaving. Activating the one on the new state seems to be pretty simple of course.

EDIT: Okay, my way of thinking was accidently fixed on letting every state only know its own panel. So I will let state y know its previous panel in state x to deactivate this as soon as there is a transition to y.
« Last Edit: May 16, 2013, 05:52:11 AM by rattlehead »

rattlehead

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: NGUI Panel Management
« Reply #3 on: May 16, 2013, 07:33:32 AM »
I can't figure out how to do this efficiently. For example, I have some windows that lead to one specific window. Now I could turn off all the possible previous windows with several actions in this one specific window. But that sounds pretty dirty and it's now what I want to have it :-(

Any idea?

Thank you so far!

memetic arts

  • Full Member
  • ***
  • Posts: 140
    • View Profile
Re: NGUI Panel Management
« Reply #4 on: May 16, 2013, 07:48:14 AM »
To deactivate, you set up the "Activate" action, but uncheck the option that says "Activate".

I'm using multiple panels in NGUI as well, and I found that one kind soul out there wrote a Custom Action to handle multiple objects at one time.  So you can turn off the N number of panels you don't want to see and turn on the one that you do (with an additional, single, Activate action).

You can grab it from one of the posts in this thread:

http://hutonggames.com/playmakerforum/index.php?topic=570.0

good luck!

rattlehead

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: NGUI Panel Management
« Reply #5 on: May 16, 2013, 10:11:25 AM »
Ok, that's a possible solution. Thanks a lot for your help!

Is it possible to set variables for one specific state instead of the complete FSM?

memetic arts

  • Full Member
  • ***
  • Posts: 140
    • View Profile
Re: NGUI Panel Management
« Reply #6 on: May 17, 2013, 09:57:54 AM »
Glad to help.

RE: variables . . . I don't think you can scope a variable to a specific state. But if you create a local variable that is only used by one state, wouldn't that accomplish the same thing?

What are you trying to do?

rattlehead

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: NGUI Panel Management
« Reply #7 on: May 20, 2013, 03:05:20 AM »
Well, I was thinking about letting every state know its previous states automatically by code. Now if every state has a very own variable with its GUI Panel attached the next state could just ask for that variable and disable it.

However, I worked some hours on it and now I have a pretty big FSM that is managing all the windows perfectly. Playmaker is great ;D

I also wrote a custom action based on your script including some fancy transition using the alpha value of the ngui panels :) (Of course I can upload it if anyone needs it. Only a few lines of code in a coroutine)