Tasharen Entertainment Forum

Support => Other Packages => Topic started by: vip_prizrak_3 on January 28, 2014, 09:37:21 AM

Title: HUDText Bug
Post by: vip_prizrak_3 on January 28, 2014, 09:37:21 AM
Hi.
I have a some problem with HUDText.
When I call Add() the first time all works fine: text appears in the starting position, moves up and gradually receding into invisibility. 
When I call Add() the second time I have bug or something like:
1) text appears in the position where he disappeared in previous times and text is fully visible;
2) then text disappears;
3) text appears in the starting position;
4) moves up;
5) gradually receding into invisibility;
and this is repeated every next time.
This is clearly seen when object with HUDText.cs has only one child object(pop-up message with name "0").
Maybe incorrect sequence of operations to change the start position of the text and its transparency in HUDText.cs?

Version of HUDText 1.9.
Title: Re: HUDText Bug
Post by: ArenMook on January 28, 2014, 02:22:05 PM
What version of NGUI are you using? I don't see any issues with the provided second example. Can you reproduce it there?
Title: Re: HUDText Bug
Post by: vip_prizrak_3 on January 29, 2014, 08:20:46 AM
NGUI wersion 3.0.9(f2).
No, I can't reproduce it in second scene((
I create test-scene,added my prefab with HUDText, added button and when push the button call Add("test", Color.red, 0.1f) and all works. But in the game is not working properly.
In the game in Update() I print to log the position and color pop-up message, when object isActive:
Debug.LogWarning(transform.localPosition.y+ " : "+ GetComponent<UILabel>().color);
and I got:
0 : RGBA(0.000, 1.000, 0.000, 1.000).
If look to log all right.
But then i printed to log in OnGUI() I got:
39.99947 : RGBA(0.000, 1.000, 0.000, 1.000)
39.99947 : RGBA(0.000, 1.000, 0.000, 1.000)
0 : RGBA(0.000, 1.000, 0.000, 1.000)
0 : RGBA(0.000, 1.000, 0.000, 1.000)
0.006145842 : RGBA(0.000, 1.000, 0.000, 1.000)
Object becomes visible in a position where he disappeared last time.
With previous version HudText ang NGUI 2.7 everything worked,  but now I do not know what can be done.
If you have time please see video: http://youtu.be/8pkOMbmNR3g (http://youtu.be/8pkOMbmNR3g)
Title: Re: HUDText Bug
Post by: ArenMook on January 29, 2014, 10:59:24 AM
HUDText is meant to be used from Update(), and never from OnGUI. If you use it from OnGUI, then a label will be enabled, but the positioning logic won't run until the next frame.
Title: Re: HUDText Bug
Post by: vip_prizrak_3 on January 29, 2014, 11:43:21 AM
I don't used HUDText from OnGUI.
I only call Add() when intersect with object or message will come, but I don't do this from OnGUI(((
Title: Re: HUDText Bug
Post by: ArenMook on January 29, 2014, 11:19:30 PM
So where do you call it from then? It should be from Update().
Title: Re: HUDText Bug
Post by: vip_prizrak_3 on January 30, 2014, 04:37:04 AM
During the test I printed to log a message about the position and color on OnGUI() and Uddate().
But in game was the intersection with the trigger and there I call the function Add().
Title: Re: HUDText Bug
Post by: ArenMook on January 30, 2014, 12:21:19 PM
So... Physics? Same thing applies. It must be done from Update(). You generally should never do any UI interaction from physics functions. Disabling panels there will cause an error for example. Start a coroutine from your physics callback. Inside that coroutine do your Add().
Title: Re: HUDText Bug
Post by: vip_prizrak_3 on January 30, 2014, 12:54:31 PM
no, it did not help((
text first appears in the position where it was ended, and then become the starting.

When I call Add() by pressing a button all works fine, but when comes to me some a message from the server - it happens.
Title: Re: HUDText Bug
Post by: ArenMook on January 30, 2014, 05:05:46 PM
What message from the server? What's the actual call stack?
Title: Re: HUDText Bug
Post by: vip_prizrak_3 on February 04, 2014, 07:52:14 AM
I fixed all.
Messages received from the server I added to the list. And then in Update() I added them from the list to HUDText.Add().
Thanks for helping.