playMaker

Author Topic: NGUI slider + Playmaker help  (Read 2820 times)

Kfinn

  • Playmaker Newbie
  • *
  • Posts: 8
NGUI slider + Playmaker help
« on: July 25, 2014, 07:25:48 PM »
Hi all.

Not sure how stupid this question is but as a non-coder, I can't figure out how to get Playmaker and NGUI to play together to create a solution to what I need.   The NGUI slider defaults to 0 to 1 as the first and last values.  I simply want the slider to go from 0 to a bigger number, say 120.  Each time I move the slider I'd like the number to increment or decrement by 1, not some tiny fraction.  I thought this would be easy with playmaker actions tied to the output of the NGUI slider but I can't seem to figure it out.   Any ideas?  Thanks!!!

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: NGUI slider + Playmaker help
« Reply #1 on: July 25, 2014, 08:56:38 PM »
NGUI slider goes from 0 to 1... this is NGUI framework.

so in order to get 120 as you want it, you would have to divide  1/120= 0.0083 would be one %.

lets make it 100 for sake of simplicity. you would use float variables. so if you wanted health to be on 5%, you would put in value 0.05, if you wanted it on 50%, you would put in 0.5

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: NGUI slider + Playmaker help
« Reply #2 on: July 31, 2014, 06:46:25 AM »

Kfinn

  • Playmaker Newbie
  • *
  • Posts: 8
Re: NGUI slider + Playmaker help
« Reply #3 on: August 04, 2014, 01:55:27 PM »
Thx Jean and bizilux!  My slider now moves from 0 to 120 (or whatever number I chose).  Jean's custom action was a simple solution and had the same result as what I had implemented based on bizilux's advice.

I guess my only issue now is the round-off problem.  I need my slider to move in increments of 1 from 0 to 120.  When I round the sliderval float up, down or to nearest, the roundoff error makes you periodically skip numbers on the scale.  I tried changing the code within NGUI's UIProgressBar so I could have as many steps on the slider as needed.  I figured that setting the number of steps = 120 would mean each movement on the slider would be +/- 1.  No such luck.

Thanks for any help you can offer!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: NGUI slider + Playmaker help
« Reply #4 on: August 05, 2014, 06:27:24 AM »
Hi,

 Then you need to work from scratch with Ints, don't work with floats.

else, make sure you really maintain floats separated from the actual result you display and the slider value you inject in ngui, create a specific float value that you use to slide virtually, and use another float that you round off for when you inject in the slider itself.

Also, have looked in ngui forum and asked for this? I am sure many ngui users wanted to the same thing.


 Bye,

 Jean

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: NGUI slider + Playmaker help
« Reply #5 on: August 05, 2014, 01:40:58 PM »
you can try using:  convert float to int
and then underneath it,  convert int to float

this should solve it