Welcome,
Guest
. Please
login
or
register
.
January 21, 2025, 12:24:20 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UISlider
« previous
next »
Print
Pages: [
1
]
Author
Topic: UISlider (Read 6794 times)
Alex
Guest
UISlider
«
on:
April 14, 2012, 10:16:44 AM »
Hi,
I still need to use ForceUpdate in order to update the UISlider.
please add it to your fix list.
Thanks
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UISlider
«
Reply #1 on:
April 14, 2012, 01:57:10 PM »
A small reproduceable example would help a lot because I couldn't reproduce the problem when I tried.
Logged
Alex
Guest
Re: UISlider
«
Reply #2 on:
April 15, 2012, 04:48:23 AM »
using
UnityEngine
;
public
class
CSoundControl
:
MonoBehaviour
{
public
UISlider musicSlider
;
public
UISlider soundSlider
;
void
Start
(
)
{
UIEventListener
.
Get
(
soundSlider
.
gameObject
)
.
onPress
+=
OnSoundReleased
;
UIEventListener
.
Get
(
musicSlider
.
gameObject
)
.
onPress
+=
OnMusicReleased
;
if
(
musicSlider
!=
null
)
{
musicSlider
.
sliderValue
=
GenericService
.
GetMusicVolume
(
)
;
if
(
CMusic
.
instance
!=
null
)
{
CMusic
.
instance
.
Play
(
MusicType
.
Game
,musicSlider
.
sliderValue
)
;
}
}
if
(
soundSlider
!=
null
)
{
soundSlider
.
sliderValue
=
GenericService
.
GetSoundVolume
(
)
;
}
musicSlider
.
ForceUpdate
(
)
;
}
void
OnMusicVolume
(
)
//musicSlider function - event
{
if
(
CMusic
.
instance
!=
null
&&
musicSlider
!=
null
)
CMusic
.
instance
.
SetVolume
(
musicSlider
.
sliderValue
)
;
}
void
OnSoundVolume
(
)
{
}
//soundSlider function - event
void
OnSoundReleased
(
GameObject go,
bool
pSet
)
{
if
(
pSet
!=
true
)
{
if
(
CSound
.
instance
!=
null
)
{
CSound
.
instance
.
SetVolume
(
soundSlider
.
sliderValue
)
;
CSound
.
instance
.
Play
(
soundSlider
.
sliderValue
)
;
}
GenericService
.
SetSoundVolume
(
soundSlider
.
sliderValue
)
;
}
}
void
OnMusicReleased
(
GameObject go,
bool
pSet
)
{
if
(
pSet
!=
true
)
{
GenericService
.
SetMusicVolume
(
musicSlider
.
sliderValue
)
;
if
(
CMusic
.
instance
!=
null
)
if
(
!
CMusic
.
instance
.
IsPlayaing
(
)
)
CMusic
.
instance
.
Play
(
MusicType
.
Menu
,GenericService
.
GetMusicVolume
(
)
)
;
}
}
}
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UISlider
«
Reply #3 on:
April 15, 2012, 05:01:15 AM »
Thanks, but CMusic, CSound, GenericService, etc... You're using classes here that don't exist in the NGUI's package, therefore I can't run it.
Logged
Alex
Guest
Re: UISlider
«
Reply #4 on:
April 15, 2012, 05:24:49 AM »
using UnityEngine;
public class CSoundControl : MonoBehaviour
{
public UISlider musicSlider;
public UISlider soundSlider;
void Start()
{
UIEventListener.Get(soundSlider.gameObject).onPress += OnSoundReleased;
UIEventListener.Get(musicSlider.gameObject).onPress += OnMusicReleased;
musicSlider.sliderValue = 1f;
soundSlider.sliderValue = 1f;
//musicSlider.ForceUpdate();
}
void OnMusicVolume()
{
}
void OnSoundVolume() { }
void OnSoundReleased(GameObject go, bool pSet)
{
}
void OnMusicReleased(GameObject go, bool pSet)
{
}
}
Logged
Alex
Guest
Re: UISlider
«
Reply #5 on:
April 15, 2012, 04:54:15 PM »
Hi,
I wonder if my code helped you reproduce the problem with UISlider.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UISlider
«
Reply #6 on:
April 15, 2012, 07:39:26 PM »
Hey Alex, yes it has, thank you. Line 136 of UISlider.cs, change it from:
Set
(
rawValue,
false
)
;
to:
Set
(
rawValue,
true
)
;
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UISlider
«
Reply #7 on:
April 15, 2012, 07:42:13 PM »
Btw, if you don't want to modify the code, simply set your sliders to start at 1.0 by adjusting the "Value" in the inspector. Same effect.
Logged
Alex
Guest
Re: UISlider
«
Reply #8 on:
April 16, 2012, 02:41:16 AM »
Thanks Aren, that's solved the problem,hope to see the fix in the next version or else
i'll forget i made changes to UISlider in line 136 when new version will come.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UISlider
«
Reply #9 on:
April 16, 2012, 09:14:41 AM »
It's already fixed in 2.0.1
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UISlider