Author Topic: Label does not appear in Scrollview until touched  (Read 10885 times)

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Label does not appear in Scrollview until touched
« on: January 07, 2014, 10:32:45 AM »
Hey there,

First of all: I'm using the latest NGUI Version.

The problem:

So, I'm controlling my UI via PlayMaker and HOTween which works fine. There is only one thing which doesn't work well.
I have a Booksystem with Buttons, when I hit these Buttons the Items on the displayed "Pages" fade out (I'm tweening the Alpha-Values of the Sprite-Objects, be default all the Alpha-Values are set to 0 and are faded in when the Menus are shown)
This works well, but not with my Quest-Scrollview.

Here's a video a made, so you can see what I mean:

https://www.dropbox.com/s/kspgtrymmdh0ex8/ScrollviewProb.mp4

As said, the default Alpha-Value is 0. When I hit "QUESTS" the "Overview"-Label is faded in, as intended, but the "Quest 1"-Label is not, though in the Inspector you can see how the Alpha-Value is slowly rising to 255 (from black to white). As soon as I actually TOUCH the Scrollview the Label appears. And then if I switch between the Menupages it works like it should.
I also tried to use the Reposition()-Function of the Grid but it didn't work.

Here's the Hierarchy of the UI.



Any suggestions?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #1 on: January 08, 2014, 01:45:13 PM »
I'm going to venture a guess and assume you are trying to tween a private variable -- "MColor"?

You need to use AnimatedAlpha intermediate script, and tween its alpha value instead. Either that, or use NGUI's tweens instead of HOTween.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #2 on: January 08, 2014, 05:24:54 PM »
No, I just tweened the alpha value of the Label.

I did it within the Visual Editor of HOTween, but via script it would be like: "label.alpha"

I tried it also by using TweenAlpha.Begin() and the AnimatedAlpha Script, same problem occurs. First time it doesn't fade in, I have to touch the scrollview, then it works with TweenAlpha.Begin() and the AnimatedAlpha-Value.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #3 on: January 08, 2014, 10:02:33 PM »
I am not aware of anything that would have this effect. Have you tried making the page semi-transparent to see if the scroll view actually appearing behind your page? Perhaps your settings on the scroll view panel is wrong?

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #4 on: January 09, 2014, 06:08:12 AM »
I tried, but my setup seems ok. It wouldn't make any sense anyway, since it works the very moment I click/touch on the scrollview.

chiuan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 6
  • Posts: 11
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #5 on: January 09, 2014, 07:22:46 AM »
I am not aware of anything that would have this effect. Have you tried making the page semi-transparent to see if the scroll view actually appearing behind your page? Perhaps your settings on the scroll view panel is wrong?

i have this error too.. i am not change the label of items. but i change my scrollView Panel's alpha. but even i dont change alpha. when Add child into scrollView cant see. except i touching the item when begin or drag items when sometimes.

by the way, i cant see any draw call in ScrollView Panel,but in parent panel....

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #6 on: January 09, 2014, 07:02:23 PM »
If you can reproduce the problem in a clean scene and provide me with an example showing it break, I would appreciate it and would have a look at it. Two things though -- first, please don't post it in public unless NGUI code is not a part of it. Email it to me at support at tasharen.com, or PM me the download link here. And second... I likely won't be able to have a look at it until after I return from vacation. I'm in Jamaica right now until the night of the 16th.

fpuig

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 6
  • Posts: 34
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #7 on: January 10, 2014, 01:36:09 AM »
I found this issue as well.

All the sliding panels that I populate by code where not creating drawcalls for the new sprites.
When the panels were touched, they recognize the new widgets and create the drawcalls.

To temporally solve the issue, after I added all widgets to the panel, I call panel.Refresh()

The problem doesn't just happen when new widgets are created, but when they are enabled as well.
To reproduce the issue, just create a panel with a few sprites and disable them in the editor. When the game starts, the panel will see that there is no active widget and will not create drawcalls for them. Then when the widgets's gameObject are enabled by code, the drawcalls will not be created until the panel is manually refreshed or by using a ScrollView and touching the collider to move the panel.

radimoto

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #8 on: January 12, 2014, 10:20:20 AM »
I think I might be experiencing the same issue with 3.0.8 f7 ?

I have the following setup:

UI Root (2D) Main UI
  Camera
    Anchor
    Panel (UIPanel)
      ButtonA (UIButton, Collider)
      ButtonB (UIButton, Collider)     
    Panel - Scroll View (UIPanel, UIScrollView)
      Grid (UIGrid)
        001_OptionA (UISprite, Collider, UIDragScrollView)
        002_OptionB (UISprite, Collider, UIDragScrollView)
        ... etc

"Panel - Scroll View" has a unified anchor enabled using Left, Custom = 0.1 so it is always positioned 10% from the left. "Panel - Scroll View" is not active until "ButtonA" is pressed.

The issue I have is the Anchor doesn't work until I click within the Scroll View. Once I do that it then jumps perfectly into place. I have tried to refresh the panel and reset position of the grid, etc but can't get it to start anchored correctly.

EDIT: OK after search these forums further I have found a way to get this to work. After using NGUITools.SetActive to enable the panels, I then had to use the following:

         Panel.BroadcastMessage ("Update", SendMessageOptions.DontRequireReceiver);
         Panel.BroadcastMessage ("LateUpdate");
         
         UIGrid.Reposition();
         UIScrollView.ResetPosition();

The Scroll View is now anchored correctly. I found if I didn't use the UIGrid.Reposition() and UIScrollView.ResetPosition() the grid was locked in position and I couldn't drag it all.

All working OK now  :)
« Last Edit: January 12, 2014, 10:59:38 AM by radimoto »

ComicSans

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 6
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #9 on: January 13, 2014, 01:27:31 AM »
I had this problem as well.  While I don't understand all the internals, after an hour of digging, it seems like the issue is in these lines of UIPanel.cs UpdateWidgets():

            if (w.UpdateTransform(frame) || mResized)
            {
               // Only proceed to checking the widget's visibility if it actually moved
               bool vis = forceVisible ||
                  (mClipping == UIDrawCall.Clipping.None && !w.hideIfOffScreen) ||
                  (w.CalculateCumulativeAlpha(frame) > 0.001f && IsVisible(w));
               w.UpdateVisibility(vis);
            }

Based on reading this, a widget can become invisible if it moves when its cumulative alpha is 0.  However, if alpha becomes nonzero (for example, its parent panel becomes visible), then UpdateVisibility won't be called again until it moves.

I temporarily hacked this in my build by running this UpdateVisibility clause if w.mChanged is true (which happened as a result of the parent alpha changed).

Thanks, Brian

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #10 on: January 13, 2014, 06:10:16 PM »
Thanks for investigating this, ComicSans. Can you try simply adding the following line to UIWidget.OnInit instead?
  1. mMoved = true;

ComicSans

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 6
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #11 on: January 13, 2014, 06:48:56 PM »
Thanks for investigating this, ComicSans. Can you try simply adding the following line to UIWidget.OnInit instead?
  1. mMoved = true;

Backing out my change and adding this line did not appear to be sufficient to resolve the issue in my case.  I believe the order of events is something like:
1) widget created
2) mMoved cleared in the next update
3) widget hidden through parent
4) widget moved (there could be another update between 3 & 4, but I don't think there is in my particular case).
5) mVisible cleared in the next update
6) widget made visible through parent
7) mVisible still false in the next update, because mMoved is still false.

Full disclosure, the vast majority of my GUI is dynamically created and laid out, as opposed to the more WYSIWYG approach that is typical to Unity, so I wouldn't be surprised if I was an outlier here.  I just spoke up since it appeared that others were having similar issues.

Edy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #12 on: January 14, 2014, 11:39:19 AM »
I'm experiencing a problem like this and I've reproduced it in a clean scene. How can I send it to you?

In summary: I have ScrollView with elements. If I click Play everything works. But if I set the Alpha value of the ScrollView (or any of its ancestors) to zero and click Play, then the elements are not displayed when the alpha is tweened back to visible.

dogmahtagram

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #13 on: January 14, 2014, 05:37:31 PM »
I've had the same issue and found a different workaround than those listed above. After adding objects to my scrollview, I call UIScrollView.MoveRelative() with a small displacement directly before calling UIScrollView.ResetPosition(). I haven't dug in to see exactly why this is working, but it's solved my issues for the time being.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Label does not appear in Scrollview until touched
« Reply #14 on: January 14, 2014, 09:02:52 PM »
The easier the repro scene, the better. I can't have a look at it right now as I'm on a beach away from home, but it's a priority for the eve of the 16th. You can send me a repro case to support at tasharen.com, but I'd prefer a dropbox link or something similar. Please don't attach NGUI's source code here.