Author Topic: bizarre situation: objects in Grid not visible?  (Read 2737 times)

jimbbq

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
bizarre situation: objects in Grid not visible?
« on: April 25, 2014, 07:57:24 AM »
Hi

I am trying to implement a simple "email" interface in my game (see the attached picture) and I run into a very bizarre situation. I have two scenes, in scene01, the email items in the grid are visible (see email01.jpg). And then I copied and pasted the same email interface to scene02 and all the emails items disappeared (see email02.jpg). The email items are added to the email interface on Start(). When I examine the Hierarchy of scene 2, I can see all the email item objects clones (under Grid, see hierarchy_scene02.jpg), but they just won't show up in my game!??

Does anyone have any idea what might have caused this?

Regards
Jim

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: bizarre situation: objects in Grid not visible?
« Reply #1 on: April 25, 2014, 10:14:59 AM »
In which version of NGUI?

jimbbq

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: bizarre situation: objects in Grid not visible?
« Reply #2 on: April 25, 2014, 10:34:32 AM »
version 3.5.7 I am using.... i figured out the problem, somehow at some point, the Y coordinate of "ScrollView" was changed from 0 (when the email items are visible) to -632.076 (when obviously the email items are invisible...)

I don't why the scrollview coordinate got changed though..... as the only thing I imagine could affect the scrollview is the code I used to update the scrollbar attached to the scrollview:

scrollview.GetComponent<UIScrollView> ().UpdateScrollbars (true);


jimbbq

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: bizarre situation: objects in Grid not visible?
« Reply #3 on: April 25, 2014, 10:46:36 AM »
I just updated to 3.5.8.... the problem still persists....


further, I encountered another problem. When there is no need for scrollbar, I have again the same email interface behaving differently in two different scenes! In one scene, I can see the scroll bar even if it is not needed (emailScene02.k.jpg). And in another scene, it works fine (emailScene01.jpg). They are the same interface I just copied and pasted from one scene to another... :'(

The scrollview feature seems quite temperamental! or is it me not understanding it fully?? 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: bizarre situation: objects in Grid not visible?
« Reply #4 on: April 25, 2014, 11:00:28 AM »
Scroll bar will show if any part of the content happens to lie outside the bounds. Even if it's just 1 pixel.

Something changing the Y coordinate? You'll need to figure out what it is you're doing that causes it -- anchoring, script moving things, etc.

jimbbq

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: bizarre situation: objects in Grid not visible?
« Reply #5 on: April 25, 2014, 11:18:53 AM »
the scrollbar problem persists even in situations where there is no item at all in the scrollview......what could have caused that?

I will look into the coordinate changing more carefully! thanks

jimbbq

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: bizarre situation: objects in Grid not visible?
« Reply #6 on: April 27, 2014, 04:17:54 PM »
I am afraid I still can't solve the problem of the scrollbar showing even there is no item at all in the scrollview..... any idea what may have caused the problem?

thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: bizarre situation: objects in Grid not visible?
« Reply #7 on: April 28, 2014, 12:08:38 AM »
The code in the scroll view will hide the scroll bar by fading it out if it's not needed. Whether it's needed or not can be determined by checking the bounds of the content (orange rectangle) against the bounds of the scroll view (pink rectangle). If the content lies outside the scroll view's bounds, the scroll bar will need to be shown. It's also not possible for the scroll bar to fade if the scroll bar itself doesn't have a widget on it. For example, if you drag in the "Control - Simple Scroll Bar", you can fade the scroll bar in or out by simply adjusting the color's alpha on the sprite residing on the same object as the Scroll Bar script.

You can check the logic that runs for the scroll bar visibility on lines 852 and 860 of UIScrollView.cs.