Author Topic: Having issues Regarding UIWrapContent  (Read 2465 times)

aammfe

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Having issues Regarding UIWrapContent
« on: October 21, 2016, 06:23:34 AM »
Hi!

i m having some difficulties regarding UIWrapContent

this script attached to wrapConent GameObject

  1. public class wrapConentHelper : MonoBehaviour {
  2.  
  3.        
  4.         void Start ()
  5.     {
  6.         GetComponent<UIWrapContent>().onInitializeItem += OniniItem;
  7.         }
  8.  
  9.  
  10.  
  11.  
  12.     private void OniniItem(GameObject go, int wrapIndex, int realIndex)
  13.     {
  14.         print(wrapIndex + " wrapIndex   " + realIndex + "  realIndex");
  15.     }
  16. }
  17.  

set wrapConent limit to 0 - 1.

animation
https://we.tl/3Q5rlABJdE

see console in animation

why realIndex is >0




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Having issues Regarding UIWrapContent
« Reply #1 on: October 24, 2016, 06:51:10 AM »
Real index isn't limited by anything. It's your actual offset.

aammfe

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Having issues Regarding UIWrapContent
« Reply #2 on: October 24, 2016, 01:29:18 PM »
so what should i do ?
assuming realIndex = dataIndex

if (realIndex > data.count)
{
;
    //error
}


 

aammfe

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Having issues Regarding UIWrapContent
« Reply #3 on: October 25, 2016, 05:26:11 AM »
i m attaching animation with this post . plz take a look on it ,
WrapContent
Range is -1 => 0
there is only one item
but when we scroll item shift it self
https://we.tl/6gcy2IIJva


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Having issues Regarding UIWrapContent
« Reply #4 on: October 30, 2016, 11:46:08 AM »
The range needs to be greater than the number of items in the list, or it simply won't work. As a rule of thumb, if your scroll view can display 5 items at a time, you should have 7 items inside it -- padding of 1 on each end.

Real index is just an offset, as I said. It doesn't represent your data index, whatever that is. You can use it to calculate your data index, however. For example if your data is always 0 to 4 range, you can just take the real index and mod it by 5 (abs(real) % 5). I don't know what your "data index" is, so I can't suggest anything specific.