Author Topic: 3.0.7f3 Upgrade, now TweenAlpha broken  (Read 3270 times)

ricky

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 15
    • View Profile
3.0.7f3 Upgrade, now TweenAlpha broken
« on: December 18, 2013, 10:56:14 PM »
Is there a temporary fix for this issue?  I am having a problem with this update.  The errors with uirect and tweenalpha.  I'm not having problems with any other tweens.

I tried the thread http://www.tasharen.com/forum/index.php?topic=7210.0 but that did not help me, i am not adding a child or anything.  I'm simply doing what I did before, make the gameobject active, then get reference to the component, but for some reason, getcomponent does not work with this update with tweenalpha.  I have not changed any code and this coe has worked for a good 4 months now in the same project.

***Error***
NullReferenceException: Object reference not set to an instance of an object
TweenAlpha.set_value (Single value) (at Assets/NGUI/Scripts/Tweening/TweenAlpha.cs:35)
TweenAlpha.OnUpdate (Single factor, Boolean isFinished) (at Assets/NGUI/Scripts/Tweening/TweenAlpha.cs:41)
UITweener.Sample (Single factor, Boolean isFinished) (at Assets/NGUI/Scripts/Tweening/UITweener.cs:282)
UITweener.ResetToBeginning () (at Assets/NGUI/Scripts/Tweening/UITweener.cs:349)
MsgDisplay.ScheduledMessageDisplay (System.String message, MESSAGESTYLE messageStyle, System.String spriteName) (at Assets/Scripts/GUI/MsgDisplay.cs:56)
MsgDisplay.DisplayMessage (System.String message, MESSAGESTYLE messageStyle, System.String spriteName) (at Assets/Scripts/GUI/MsgDisplay.cs:76)
PlayerMovement.CheckVelocity () (at Assets/Scripts/PlayerMovement.cs:2260)
PlayerMovement.Update () (at Assets/Scripts/PlayerMovement.cs:596)

***Code***
 GameObject msg = msgs.Dequeue();
        msgs.Enqueue(msg);
        msg.SetActive(true);
        msg.GetComponent<TweenScale>().ResetToBeginning();
        msg.GetComponent<TweenScale>().enabled = true;
        msg.GetComponent<TweenPosition>().ResetToBeginning();
        msg.GetComponent<TweenPosition>().enabled = true;
        msg.GetComponent<TweenAlpha>().ResetToBeginning();
        msg.GetComponent<TweenAlpha>().enabled = true;
        float timeToDisplay = SetMessageStyle(messageStyle, msg);
        msg.GetComponentInChildren<UILabel>().text = message;

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3.0.7f3 Upgrade, now TweenAlpha broken
« Reply #1 on: December 19, 2013, 10:54:58 AM »
You need to attach TweenAlpha to a widget or a panel. In your example you do msg.GetComponentInChildren<UILabel> -- I'm guessing your widget (label) is on a child object. This is the object you need to TweenAlpha.

ricky

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: 3.0.7f3 Upgrade, now TweenAlpha broken
« Reply #2 on: December 19, 2013, 03:45:59 PM »
You need to attach TweenAlpha to a widget or a panel. In your example you do msg.GetComponentInChildren<UILabel> -- I'm guessing your widget (label) is on a child object. This is the object you need to TweenAlpha.

Thanks!

I put the tween alpha on the children and removed it from the parent and it works fine now:

TweenAlpha[] tas = msg.GetComponentsInChildren<TweenAlpha>();
        foreach (TweenAlpha ta in tas)
        {
            ta.ResetToBeginning();
            ta.enabled = true;
        }