Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: aammfe on October 21, 2016, 06:23:34 AM

Title: Having issues Regarding UIWrapContent
Post by: aammfe 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 (https://we.tl/3Q5rlABJdE)

see console in animation

why realIndex is >0



Title: Re: Having issues Regarding UIWrapContent
Post by: ArenMook on October 24, 2016, 06:51:10 AM
Real index isn't limited by anything. It's your actual offset.
Title: Re: Having issues Regarding UIWrapContent
Post by: aammfe on October 24, 2016, 01:29:18 PM
so what should i do ?
assuming realIndex = dataIndex

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


 
Title: Re: Having issues Regarding UIWrapContent
Post by: aammfe 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 (https://we.tl/6gcy2IIJva)

Title: Re: Having issues Regarding UIWrapContent
Post by: ArenMook 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.