playMaker

Author Topic: NGUI Integration (WIP) [NGUI 3.5.9 supported]  (Read 150142 times)

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: NGUI Integration (WIP)
« Reply #75 on: March 06, 2013, 03:03:23 PM »
See my attachment. Yes, if this is what you are trying to do.

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: NGUI Integration (WIP)
« Reply #76 on: March 06, 2013, 04:14:59 PM »
Ah, i see. And now, a screenshot of the Actions :D :D :P

I'll try it, thank you.

Red

  • Hero Member
  • *****
  • Posts: 563
Re: NGUI Integration (WIP)
« Reply #77 on: March 06, 2013, 09:50:26 PM »
So, will this work if i put two of them on them? for instance, say i have two FSMs that i want to get information from (one being "onHover" and another being "onClick"... the "onHover" being a way to tell my monitor system to pass the information to the appropriate systems that any clicks while the mouse is over this spot to be disregarded, the other to open up a character sheet/skill-tree.)

or would the two scripts being on the same object cause issues?

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: NGUI Integration (WIP)
« Reply #78 on: March 07, 2013, 09:04:14 AM »
How can i make an FadeOut Effect (linear changing the AlphaValue from 255-0)with UI Widgets?

I triedto manipulate it via SetProperties but couldn't achieve any good results :/

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: NGUI Integration (WIP)
« Reply #79 on: March 07, 2013, 01:25:30 PM »
Use set properties as you said, it should work, alternatively use the script attached (originally from the NGUI forums) and put it on a panel or anchor to control all of the sub objects transparency.

warning that with the script it uses a scale of 0-1 not 0-255 and that if you change any of the sub objects transparency manually then it will reset to the scripts value on the next frame.

PS. use ease float action with the set property to easily animate the fade with the script below
« Last Edit: March 07, 2013, 01:27:25 PM by Sjones »

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: NGUI Integration (WIP)
« Reply #80 on: March 07, 2013, 01:52:52 PM »
Mhm, i am trying it without the script.
So i made my first state:


And that is my second state



Doesn't work. I know it's not that difficult, i just didn't figured out yet the proper using of Properties and Variables.

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: NGUI Integration (WIP)
« Reply #81 on: March 07, 2013, 02:16:37 PM »
the only reason to use to get property in this instance is if you want to animate from a partially faded UI element that you dont know how much has faded.

If this is the case, this would be your start value (ease float "from value")

otherwise remove the get property and create a Set property after the ease float.

set the alpha property in the set property action like you did with the get property

and then set the set property "every frame" check box to active

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: NGUI Integration (WIP)
« Reply #82 on: March 07, 2013, 02:40:21 PM »
It's otherwise, yeah. Tried that out:



Doesn't work. It kind of ignores the EaseFloat-Action (well, it goes through the action, but nothing happens), only when i fool around with the AlphaValue in the "Set Properties" Action it makes a difference, and i don't just want to set it to 0, but to yeah easefloat it :D

And i don't understand this approach quite well. My FSM on my GameObject has to know that i want access its UISpriteComponent and change the Alpha-Value. I don't get how i can make an "Ease Float"-Action on the float-settings BEFORE telling it which float (the Alpha Value) i want to manipulate.

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: NGUI Integration (WIP)
« Reply #83 on: March 07, 2013, 06:46:12 PM »
think of it as the easing float and the alpha separately.

your setting a float number with the ease float - at this point this is just a generic decimal number, can be used for anything from object position, time to wait, how much force to use OR an alpha for a gui element

so this number will no matter what you do with it animate from the low number to the high.

you are then using this number after to change the assigned number to the alpha value (or anything else that you want to effect with a float)

to put this into perspective, you could even generate this animated float and not use it for anything - pointless yes - but playmaker will keep this number going, further more you could then assign it to something at any point in your game and if its still being animated, it will animate the thing you assigned it to.

-BUT for this instance, as its animating over time and not a single frame calculation, the ordering of the two makes very little difference -

just going over this myself, it looks like your main issue though is your setting the wrong property, instead use the colour property and choose the a. from the list, the alpha is controlled in the colour tint rather than that alpha setting

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: NGUI Integration (WIP)
« Reply #84 on: March 08, 2013, 03:41:44 AM »
Yeah, i figured it out. Thank you very much for your time and explanation, helped a lot! :)

I just want to mention that i get some drastic FrameRateDrops on the PC; i use for example two of such FSM, which fade two objects out/in (i made them for the moment infinite, so the fade out and after 2 seconds the fade back in)
In a Script i attached to my camera i  made a line:
"Application.targetFrameRate = 60;"
On my TargetDevice (iPhone4) the FrameRate is pretty constant, it stays between 58-60 FPS, but on the PC it goes from 60 down to 20. If i disable the FSM and play the game, the FPS are at least back at 50.

Red

  • Hero Member
  • *****
  • Posts: 563
Re: NGUI Integration (WIP)
« Reply #85 on: March 08, 2013, 08:37:55 AM »
Allrighty, i'm learning more about this but for some reason i cannot find the right value with the get-property action.

what i'm trying to do is gain access to the "OnHover" boolean value that's apparently available to be extracted from a button. Any help would be much appreciated.

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: NGUI Integration (WIP)
« Reply #86 on: March 08, 2013, 03:41:02 PM »
@ mayhem, PC speed should be running a lot faster than your mobile device, if your PC is running slower FPS than a mobile device your issue could possibly be with your PC specs

for example on my android phone (xperia s) my game runs at 30 fps, on my PC in editor runs at 400 FPS, as a standalone exe it runs at 1000 FPS

@ Red, the onhover is gotten from the NGUItoPM script on the first page of this thread

attach it to the button and when you go on hover, it will send an event, the event by default is OnHover but you can change it in the scripts properties to send what ever event you like.
« Last Edit: March 08, 2013, 03:42:39 PM by Sjones »

Red

  • Hero Member
  • *****
  • Posts: 563
Re: NGUI Integration (WIP)
« Reply #87 on: March 08, 2013, 04:37:04 PM »
@ mayhem, PC speed should be running a lot faster than your mobile device, if your PC is running slower FPS than a mobile device your issue could possibly be with your PC specs

for example on my android phone (xperia s) my game runs at 30 fps, on my PC in editor runs at 400 FPS, as a standalone exe it runs at 1000 FPS

@ Red, the onhover is gotten from the NGUItoPM script on the first page of this thread

attach it to the button and when you go on hover, it will send an event, the event by default is OnHover but you can change it in the scripts properties to send what ever event you like.

I'm not seeking the events, that works just fine... what i need for my system is a way to detect when the button is and is not having the mouse over it. using the event script only sends events as far as i can tell looking at the code... what i need is the actual boolean value that NGUI uses to indicate that it's hovering or if it's not hovering (i guess there are other ones too but i haven't looked into those scripts.)

so, it's not the event, it's the bool(s) that i'm after.

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: NGUI Integration (WIP)
« Reply #88 on: March 08, 2013, 07:41:15 PM »
I understand what you mean but I am nos sure if there is a difference.

a get property must be always running to get the bool value as soon as it changes, meaning that you will have to either have strategically placed fsm's to get the bools property when you need it, or a generic fsm that updates every frame.

and then depending on the bool value to do something. (e.g. if not hovering do nothing - if hovering do something)

meaning that instead of a get property and a bool test every frame you can just have an event out of your state that is then fired at the same locations as above (even if its to to a state to turn a bool to true to use else where) using the UIevents to PM script

as I have never used on hover (cant onhover a touch on a screen...) I am only guessing that the onhover is fired a second time when un-hovering, in which case use a bool flip on the event that is fired from the UIevent to PM


Red

  • Hero Member
  • *****
  • Posts: 563
Re: NGUI Integration (WIP)
« Reply #89 on: March 08, 2013, 08:20:58 PM »
No, that's the thing... I don't need to have an action detect when it's hovering per-se, i need to know when it's not hovering.

The problem i'm trying to address is that the weapons are firing their actions even when the player is trying to access the menu. I've tried it with a raycast from the screen to detect when it's over a GUI layer item but that doesn't work with NGui (or regular Unity GUI stuff)

the only work-around i've come up against would be to hard-code an area of the screen as being off-limits but that doesn't take into account dynamic menu stuff which is kinda what i'm aiming for.

not to mention the systems are abhorrently difficult to make sense of... so, for a corner area, i'd have to set up a mouse screen system that extracts the values of the mouse, compare each value independantly and if it's greater/lower than a certain amount, then fire off the appropriate actions... this is really only useable for a "one side" approach and the system becomes nightmarishly convoluted to set up a small X by Y rectangle in the corner since i have to use multiple FSMs to even filter that... So, if you want to get technical, yes, i am fully intending on having a "get property every frame" action and threading it into another FSM that manages these states since that has a much lower overhead than the whole screen-space juggling act. And the biggest weakness for this? it only works with a set resolution since the X and Y values are going to be different (unless it's in the bottom-left corner only) whether it's normalized or not.

So, if there were a way to extract from these the state of the onHover, onClick, onTooltip, etc... then i can use that...

so, to reiterate, i don't need to know when "onHover" fires, i need to know when it turns off. the system as is doesn't seem to want to allow me to gain access to that information and from the NGui people, it's apparently just a boolean value that ngui threads to the various scripts... and i can easily work with boolean values no-problem (and it makes it a very simple FSM system to set up and maintain since it's just a few actions that are running every frame so CPU power isn't consumed as much as the only workaround i've managed to find to address this issue.)
« Last Edit: March 08, 2013, 08:28:41 PM by Red »