I say "possible" because i am new to NGUI and the way I approach my problem could simply be the wrong one.
Imagine 2 buttons button A and Button B. Both Buttons have a UIButtonComponent and a TweenAlpha Component as well.
On program start button A is visible and Button B is invisible because its alpha is set to zero (Set in the UISprite Component).
When I click button A it disappears and button B appears. When I click Button B the same stuff happens only the other way around.
Here is the problem:After clicking button A and button B became visible. When I hover over button b and then unhover it again it simply fades away.
I am using the current version of NGUI 3.5.5.
I have localized a possible cause for this to happen.
The UIButtonColor Component uses the initial color of the widget to return to when no other state like hover or isPressed is true. But because the initial colorValue of the buttonWidget has an alpha of zero the button simply fades away.
Here are the parts of code in UIButtonColor I am talking about:
protected virtual void OnInit ()
{
mInitDone = true;
if (tweenTarget == null) tweenTarget = gameObject;
mWidget = tweenTarget.GetComponent<UIWidget>();
if (mWidget != null)
{
mColor = mWidget.color; }
else
// other stuff
____________________________________________________________________________
// this is in the SetState method
switch (mState)
{
case State.Hover: tc = TweenColor.Begin(tweenTarget, duration, hover); break;
case State.Pressed: tc = TweenColor.Begin(tweenTarget, duration, pressed); break;
case State.Disabled: tc = TweenColor.Begin(tweenTarget, duration, disabledColor); break;
default: tc = TweenColor.Begin(tweenTarget, duration, mColor); break; }
The variable mColor is only set in the OnInit method and (at least to my knowledge) never updated afterwards.
Should this variable not be updated from TweenAlpha or TweenColor as well?
Am I getting something wrong here?
If not: Where do I have to change the code to solve the problem and not causing a terrible number of new bugs to occur?
If anything is unclear then please tell me.