Search Unity

Optimized ScrollView Adapter + Playmaker support

Discussion in 'Assets and Asset Store' started by xucian, Apr 1, 2016.

  1. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    I found, that if you have datetimepicker-like adaper already in scene, i.e. not instantiate it, in
    OSAPercentageContentPaddingSetter Awake should be replaced by Start method (or better manually call OSAPercentageContentPaddingSetter Start() code after OSA base.Start()). Also,_FirstLastItemsInsidePercent should be 1 for preventing last element move outside top border. In this case, list will starts from index 1, so it should has one additional element. Also, in UpdateGalleryEffectIfNeeded after "t01 = 1d - Math.Max(0, Math.Min(1d, t01));" should be checked "if (double.IsNaN(t01)) t01 = 0;" or sometimes it throws an error.
     
    Last edited: Apr 22, 2019
  2. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Can you expand on why this is needed?
    At the first glance, this is exactly the opposite of that the padding setter script needs. Look at this line in its Awake:
    Code (CSharp):
    1.             if (_IOSA.IsInitialized)
    2.             {
    3.                 Debug.Log(typeof(OSAPercentageContentPaddingSetter).Name + " needs the OSA component to not be initialized before it");
    4.                 return;
    5.             }
    You mean the first element can't be shown? Tweak the Padding Start Percent for this.
    If, however, you have a variable viewport/itemSize ratio, use the previous solution I mentioned - and you don't need OSAPercentageContentPaddingSetter in this case. ;)

    Did you by any chance remember what was different in the ScrollView that threw an error here?
    t01 being NaN means either a problem with wrong cached values of the vpSize or a problem in the RectTransform's inset Unity reports, which in any case needs more attention than just checking for NaN, to prevent other potential bugs.
    I didn't encounter this and I'd be grateful if you'd have some info on how to reproduce this. Thanks!

    --Lucian
     
  3. jmdeb

    jmdeb

    Joined:
    Jul 28, 2017
    Posts:
    23
    One question before buy if you don't mind: I can read that one can do drag-and-drop between 2 lists (correct?). If yes, is it possible to feed a list "B" with items coming from list "A" without displacing the item...but copying it?
    Hope that I'm clear ;) Thanks!
     
  4. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Hi there! Seems that my scene was broken, and i try to copy/paste all object form broken scene into another new one. But without any renaming, OSA throws errors after this (on play)
    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <cfc149f8218b496788d8493c87de777a>:0)
    4. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <cfc149f8218b496788d8493c87de777a>:0)
    5. System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <cfc149f8218b496788d8493c87de777a>:0)
    6. Com.TheFallenGames.OSA.Core.OSA`2[TParams,TItemViewsHolder].CollectItemsSizes (Com.TheFallenGames.OSA.Core.ItemCountChangeMode changeMode, System.Int32 count, System.Int32 indexIfInsertingOrRemoving, Com.TheFallenGames.OSA.Core.ItemsDescriptor itemsDesc) (at Assets/OSA/Scripts/Core/OSA.cs:1002)
    7. Com.TheFallenGames.OSA.Core.OSA`2[TParams,TItemViewsHolder].ChangeItemsCountInternal (Com.TheFallenGames.OSA.Core.ItemCountChangeMode changeMode, System.Int32 count, System.Int32 indexIfInsertingOrRemoving, System.Boolean contentPanelEndEdgeStationary, System.Boolean keepVelocity, System.Boolean stealInsteadOfRecycle) (at Assets/OSA/Scripts/Core/OSAInternal.cs:724)
    8. Com.TheFallenGames.OSA.Core.OSA`2[TParams,TItemViewsHolder].ChangeItemsCount (Com.TheFallenGames.OSA.Core.ItemCountChangeMode changeMode, System.Int32 itemsCount, System.Int32 indexIfInsertingOrRemoving, System.Boolean contentPanelEndEdgeStationary, System.Boolean keepVelocity) (at Assets/OSA/Scripts/Core/OSA.cs:515)
    9. Com.TheFallenGames.OSA.CustomAdapters.GridView.GridAdapter`2[TParams,TCellVH].ChangeItemsCount (Com.TheFallenGames.OSA.Core.ItemCountChangeMode changeMode, System.Int32 cellsCount, System.Int32 indexIfAppendingOrRemoving, System.Boolean contentPanelEndEdgeStationary, System.Boolean keepVelocity) (at Assets/OSA/Scripts/CustomAdapters/GridView/GridAdapter.cs:75)
    10. Com.TheFallenGames.OSA.CustomAdapters.GridView.GridAdapter`2[TParams,TCellVH].Refresh (System.Boolean contentPanelEndEdgeStationary, System.Boolean keepVelocity) (at Assets/OSA/Scripts/CustomAdapters/GridView/GridAdapter.cs:195)
    11. ChordsDbQualitySelectionAdapter.Refresh (System.Boolean contentPanelEndEdgeStationary, System.Boolean keepVelocity) (at Assets/Scripts/ChordsDbQualitySelectionAdapter.cs:31)
    12. Com.TheFallenGames.OSA.Core.OSA`2[TParams,TItemViewsHolder].Init () (at Assets/OSA/Scripts/Core/OSA.cs:460)
    13. ChordsDbQualitySelectionAdapter.Start () (at Assets/Scripts/ChordsDbQualitySelectionAdapter.cs:19)
    14.  
    And
    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <cfc149f8218b496788d8493c87de777a>:0)
    4. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <cfc149f8218b496788d8493c87de777a>:0)
    5. System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <cfc149f8218b496788d8493c87de777a>:0)
    6. Com.TheFallenGames.OSA.Core.SubComponents.ReleaseFromPullManager`2[TParams,TItemViewsHolder].CalculateFirstItemInsetFromVPS () (at Assets/OSA/Scripts/Core/SubComponents/ReleaseFromPullManager.cs:28)
    7. Com.TheFallenGames.OSA.Core.OSA`2[TParams,TItemViewsHolder].MyLateUpdate () (at Assets/OSA/Scripts/Core/OSAInternal.cs:1595)
    8. Com.TheFallenGames.OSA.Core.OSA`2[TParams,TItemViewsHolder].LateUpdate () (at Assets/OSA/Scripts/Core/OSA.cs:131)
     
  5. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey,

    The drag-and-drop functionalities you describe are provided as an example implementation. There's no rigid drag-and-drop system that you can use as a starting base - you'll copy the existing code and modify it according to your needs.
    To answer your question, yes, it's possible. But not out of the box. And you'll have to code your way into it.

    Hope this helps

    Usually, it's enough to look at the first error to solve the entire problem. Seems like something's wrong with the scrollview/prefab in the scene, or some non-standard code being called.
    Do you have an idea if it's the one or the other?
    If you've found a bit more details so I'll know where to look, you can send me the project via email and I'll check it.

    --Lucian
     
    justtime likes this.
  6. stansison

    stansison

    Joined:
    Feb 20, 2016
    Posts:
    28
    Hi Lucian,
    Like a previous poster, I am using OSA with Touchscript. Because TouchScript brings its own standard Input module, i've turned off unity's event system.
    https://github.com/TouchScript/TouchScript/wiki

    Everything is mostly working, except I'm noticing that the first touch/scroll event on the OSA scrollview/scroll element causes the list to skip a few places down. I saw that you replied to the previous poster, would you happen to know how to resolve this issue or what's causing it? (about 4-10 element down)

    Regular scrollview that don't use OSA works normally.
    I'd like to clarify that the issue only comes up on iPhone/android devices and not on mouse input.
    Touchscript Standard Layer for the mainCamera is flagged to respond to Screen Space UI and 3d Objects only.
    Transient Speed Between Drag is off
     
    Last edited: May 22, 2019
  7. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey, Welcome!

    I'll look into it. Problem is that library wasn't updated in 2 years. There may be other bugs that you'd find along the way while using it with OSA.
    To faster locate the problem, you can send me a stripped-down version of the project and your invoice number via email and I'll investigate.
    If there's a simple fix, I'll correct it for you, but if it's something the library doesn't do well, I don't guarantee I'll have time for it.
    A short video demonstrating the problem would also help (you can use DU Recorder). 5-10 secs would be enough.

    -- Lucian
     
  8. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    The underlying cause for the TouchScript problem was solved and will be present in v4.4.
    For a temporary solution, you can set the EventSystem's DragThreshold to 0, but I'd recommend to do some code changes in the OSA.
    For anyone interested, contact me via email with your invoice number and OSA version you're using and I'll give you the code. I'll also add this note to the Known issues in the manual.

    -- Lucian
     
    Last edited: May 23, 2019
  9. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Hi there! How to aplly changes after changing Adapter.GetParams().grid.alignmentOfCellsInGroup setting ?
     
  10. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Easiest is to call Refresh(), but of course if you have 10k+ items and want to update that property more than once that may make it stutter for a few frames. In this case, you'd want to modify the cell group prefab yourself in UpdateViewsHolder.

    It depends on when and where you change that setting. If you want it to be constant, just set it in inspector.
    If you set it only once, but after initialization (probably because you calculate it dynamically), calling Refresh() once after that shouldn't add noticeable stutter.

    -- Lucian
     
    justtime likes this.
  11. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Thanks, but aftert Refresh() new setting not applied
    BTW, i handled it in this way, seems works well
    Code (CSharp):
    1. foreach (Transform lg in DiagramSelectionAdapter.GetParams().Content.transform)
    2.         {
    3.             lg.GetComponent<HorizontalLayoutGroup>().childAlignment = newAnchor;
    4.         }
     
  12. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    You could use the _VisibleItems array, to get the "official" cell group VHs, instead of manually searching through the transform's children.

    Or use the UpdateViewsHolder, which directly gives you the group views holder. It's called for every visible group.
    Not to be confused with UpdateCellViewsHolder.

    Reminder: group = row, for a vertical grid

    -- Lucian
     
  13. aliak

    aliak

    Joined:
    Jan 2, 2017
    Posts:
    12
    Hi, can I pre-instantiniate some viewHolder prefabs manually and put them into
    _RecyclableItems or something like this? OSA almost always creates 1-2 additional prefabs during scrolling, so I want to avoid it. I have lags during prefab instantiation. Just fyi, I use OSA with looping enabled.
    Thank you.
     
  14. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey,

    No officially supported way of modifying _RecyclableItems yourself, but see below for a solution that I may include in the next version.
    What does "always" mean? Once every a few frames or once per OSA initialization?

    If it's the first, let me know which version you use, as I'm not seeing this with the current one (CreateViewsHolder is called only a few times at the beginning and then 1-2 times after first scrolling).

    If it's the latter, I guess you just want an initial load, and prevent more hiccups after that.
    For this, there's some more code to add and I can share it with you via email. Send me your invoice, Unity version and OSA version and I'll send you the necessary code changes you need to make.

    -- Lucian


    Edit:
    Actually, for the second case, I've found a much, much more simple solution. Using the SimpleExample class, here's what you could do:

    1. Add a field List<MyItemViewsHolder> _NewVHsBuffer = new List<MyItemViewsHolder>();

    2. Modify the Start method:
    Code (CSharp):
    1.         protected override void Start()
    2.         {
    3.             Data = new SimpleDataHelper<ExampleItemModel>(this);
    4.  
    5.             base.Start();
    6.  
    7.             int initialBuffer = 12;
    8.             var buffer = new List<MyItemViewsHolder>(initialBuffer);
    9.             for (int i = 0; i < initialBuffer; i++)
    10.             {
    11.                 var vh = CreateViewsHolder(-1);
    12.                 buffer.Add(vh);
    13.             }
    14.  
    15.             // Careful to first use the local variable during population, since CreateViewsHolder returns items from _NewVHsBuffer itself
    16.             _NewVHsBuffer.AddRange(buffer);
    17.         }
    3. Modify the UpdateViewsHolder method:
    Code (CSharp):
    1.         protected override MyItemViewsHolder CreateViewsHolder(int itemIndex)
    2.         {
    3.             // Buffered vhs available => use them instead
    4.             if (_NewVHsBuffer.Count > 0)
    5.             {
    6.                 var bufferedVH = _NewVHsBuffer[0];
    7.                 _NewVHsBuffer.RemoveAt(0);
    8.  
    9.                 bufferedVH.ItemIndex = itemIndex;
    10.                 bufferedVH.CollectViews();
    11.  
    12.                 return bufferedVH;
    13.             }
    14.  
    15.             var instance = new MyItemViewsHolder();
    16.             instance.Init(_Params.ItemPrefab, _Params.Content, itemIndex);
    17.             return instance;
    18.         }
    Update: In v4.4 (coming approx. in the mid of/late July 2019), you can use CreateBufferredRecycleableItems and AddBufferredRecycleableItems to achieve the same thing in 2 lines of code. Or, override ShouldDestroyRecyclableItem and always return false
     
    Last edited: Jul 9, 2019
  15. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Sorry, forgot to press the Reply button. See above. :)
     
  16. Jochanan

    Jochanan

    Joined:
    Nov 9, 2016
    Posts:
    85
  17. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey,
    I think it'll be 2 more weeks, based on how the work schedule looks now.
    I look forward to release 4.4. There are several improvements and fixes, most based on user feedback.

    -- Lucian
     
    Jochanan likes this.
  18. Jochanan

    Jochanan

    Joined:
    Nov 9, 2016
    Posts:
    85
    Thanks for the info @thefallengamesstudio ,
    i have another question. I have a multiple chats in the application and in the example chat, you are accessing _VisibleItems field, for popup animation.
    Unfortunatelly, it is marked as internal. I have changed it to public to be able to use it, but is there any other property, that might be used instead?
     
  19. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Are you using an old version of OSA?
    Anyway, accessing _VisibleItems just for read-only stuff shouldn't be a problem.

    -- Lucian
     
  20. Jochanan

    Jochanan

    Joined:
    Nov 9, 2016
    Posts:
    85
    i have just migrated to 4.3 (from 4.1). Had to do a couple of changes to have it working again.
     
    xucian likes this.
  21. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    That's good. Yes, updating to 4.3 requires a few changes, but it's worth it. :)
    Stay tuned for 4.4.

    -- Lucian
     
  22. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Hi there! I have to scroll to item without animation. Here is my adapter settings


    Here is behaviour

    Code:
    Code (CSharp):
    1.  
    2. ScrollTo(indexToScroll);
    3. ScrollTo(indexToScroll, 0.5f, 0.5f);
    4.  
    You can see that for "new" elements(which is not fullscreened now) it's ok.
    I tried to call only ScrollTo(indexToScroll), but it's even worse: animation shows not only for same element, but for "new" too.
    Only ScrollTo(indexToScroll, 0.5f, 0.5f) line works worse too.
     
  23. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey,

    ScrollTo by itself is an instantaneous action.
    I assume you're using Snapper, that's why the content appears to animate before scrolling, but it actually animates after, as a result of the Snapper trying to align the item.
    You were close to the solution. ScrollTo(indexToScroll, 0.5f, 0.5f) should work with the Snapper's default pivots.
    I'm pretty sure those pivots are different than the ones you're trying to scroll to.
    I've just tested this and it works. ".5f, .5f" means "bring the middle of the item in the middle of the viewport", which most users want.
    Make sure the snapper's pivots are the same as the ones you're trying to scroll to - they're shown in inspector.

    Hope this helps

    -- Lucian
     
  24. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Snapper's pivots are 0.5f,0.5f. The same is for Viewport and Content objects. OSA prefab also 0.5, 0.5.


    BTW, if disable Snapper, then this happens
     
    Last edited: Jun 21, 2019
  25. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    I see. Well, isn't this just a natural consequence of when you call ScrollTo?
    I assume you're waiting for the "fade-in" animation to finish, after which you call ScrollTo.
    Is this the case?

    If yes and you didn't modify anything along the way, I think for the snapper problem there's something wrong in the way the prefab is set up or one of the the ScrollView/Viewport/Content game objects. In which case I'll need to take a look in the project itself.

    -- Lucian
     
    justtime likes this.
  26. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Yes. This is my case. I found, that it's happens when i call "ResetItems(_Params.Data.Count);" before scroll. Without ResetItems it's ok.
    I also tried
    ResetItems(_Params.Data.Count,true) and
    ResetItems(_Params.Data.Count,true,true) and
    ResetItems(_Params.Data.Count,false,true);
    BTW seems that this is triggered only if i scroll to the latest element.
     
    Last edited: Jun 26, 2019
  27. The_Arrival

    The_Arrival

    Joined:
    Dec 3, 2014
    Posts:
    82
    Hello OSA-Support,

    i´m struggeling giving my Items in my GridView an OnClick-Listener passing the DataModel as an argument.

    With the ListView i was able to, Overriding CreateViewsHolder and applying ist on each instance.

    Code (CSharp):
    1. protected override VideoViewHolder CreateViewsHolder(int itemIndex) {
    2.             VideoViewHolder instance = new VideoViewHolder();
    3.             instance.Init(_Params.itemPrefab, _Params.Content, itemIndex);
    4.             instance.button.onClick.AddListener(delegate {ui.OnItemClicked(Data[instance.ItemIndex]); });
    5.             return instance;
    6.         }

    On the GridView i get a CellGroupViewsHolder, tried to iterate over the group and use the ItemIndex to find the right DataModel to assign it.


    Code (CSharp):
    1. protected override CellGroupViewsHolder<ItemsViewHolder> CreateViewsHolder(int itemIndex) {
    2.  
    3.             CellGroupViewsHolder<ItemsViewHolder> cellGroup = base.CreateViewsHolder(itemIndex);
    4.  
    5.             for (int i = 0; i < cellGroup.ContainingCellViewsHolders.Length; i++) {
    6.                
    7.                 ItemsModel model = Data[itemIndex];
    8.                
    9.                 cellGroup.ContainingCellViewsHolders[i].button.onClick.AddListener(delegate {
    10.                     ui.OnItemClicked(model);
    11.                 });
    12.             }
    13.  
    14.             return cellGroup;
    15.         }
    Or i used OnCellViewsHolderCreated

    Code (CSharp):
    1. protected override void OnCellViewsHolderCreated(ItemsViewHolder cellVH, CellGroupViewsHolder<ItemsViewHolder> cellGroup) {
    2.             base.OnCellViewsHolderCreated(cellVH, cellGroup);
    3.            
    4.             ItemsModel model = Data[cellVH.ItemIndex];
    5.            
    6.             cellVH.button.onClick.AddListener(delegate {
    7.                 ui.OnItemClicked(model);
    8.             });
    9.         }
    The issue is, that when the items get reused, the Listener never gets updated. In teh Listview this somehow seems to work, but in the GridView it doesn´t. I ended up doing this, which is working but maybe not the intended solution

    Code (CSharp):
    1. protected override void UpdateCellViewsHolder(ItemsViewHolder newOrRecycled) {
    2.             ItemsModel model = Data[newOrRecycled.ItemIndex];
    3.  
    4.        
    5.             newOrRecycled.button.onClick.RemoveListener(delegate {
    6.                 ui.OnItemClicked(model);
    7.             });
    8.            
    9.             newOrRecycled.button.onClick.AddListener(delegate {
    10.                 ui.OnItemClicked(model);
    11.             });
    12.         }
     
  28. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Maybe you can send me a stripped-down version of the project via email and I'll take a look? Also mention your OSA version and Unity version.

    --Lucian
     
  29. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey, welcome!

    You're lucky. This is an easy fix. Look at the 3rd FAQ here.
    In short, passing the vh itself to the click handler means you'll always know what's the index of the model it presents, because vh.ItemIndex changes (there are only a few VHs, and they constantly get reused).

    -- Lucian
     
  30. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    It's very complicated to make a stripped version now :( Unity 2017.4.28f, SRIA 4.3
     
  31. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    No problem.
    Then, can you try to describe again what exactly happens, and what should actually happen? Honestly I'm not sure I understand the whole problem by just looking at the video.
    What are you trying to do? I know you want to scroll to an item, but maybe by having context I can identify the path to solution faster.
    Do you use snapping, looping, CSF?
    Are you enabling/disabling snapping/looping by code?
    Do you (de)activate the OSA game object at certain times?
    Does OSA game object start as disabled?

    -- Lucian
     
  32. aliak

    aliak

    Joined:
    Jan 2, 2017
    Posts:
    12
    Hi,
    thank you. Works great!
     
    xucian likes this.
  33. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    I will try to prepare stripped version later. It's more easy to show compare to explain =)
    Another moment. I want to implement image slider and seems that "page_view_worldspace" example fits well. But, can i get current "swipe position". I mean value meaning transition progress between two images. So i swipe right till the middle if a screen and it must be 0.5f, swipe right little more and now it's 0.87f (left image almost fully visible).
     
  34. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey,
    YW!

    That'd be great. But also it'll be useful to go through those key-questions I prepared - saves me some time.

    About the slider you mention, let me know what are you trying to do and I'll think of solutions. The swipe position you describe would probably take too much time to get it bug-free.

    -- Lucian
     
  35. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Shure! There is desirable effect. So depending on sliding position i want to change image and text alpha, scale.
     
  36. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    For having something similar to this effect, you could first try to use the gallery effect, and in Update go through all the visible VH's and set their alpha to be exactly the same as their localScale - which with the default settings will be 1 for the middle ones, 0 for the ones at the edges. You can further apply a non-linear function on the local scale if you want the items the become invisible faster than they become smaller; or vice-versa. Try these:
    Linear: alpha = localScale.x
    Alpha decreases faster than the localScale: alpha = Mahtf.Pow(localScale.x, 2); // Can use any power bigger than 1 here to fine-tune.

    -- Lucian
     
    justtime likes this.
  37. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Hi!
    I'am also trying to adjust Event System Drag Treshhold and noticed, that on sria it works strange. Here is video: first is a native scrollrect, as you can see after touch and pass treshhold distance it starts moving smooth. Second two are sria ones. And they initial movement very sharp. Can i somehow make it smooth like native ?
     
  38. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey,

    I added support for variable drag threshold on 23 May, but this feature will make it only in v4.4, which will be released in about a week or two, I think.
    However, you can send me an email and I'll give you the code for it.

    -- Lucian
     
    justtime likes this.
  39. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey,
    I'm replying to let you know that in OSA 4.4 (will be released soon), you can use CreateBufferredRecycleableItems() or create the list of VHs yourself, then call AddBufferredRecycleableItems(vhs) before your first call of ResetItems. That's 2 lines of code.
    You can also override ShouldDestroyRecyclableItem and always return false (v4.3 it's not working as intended, but will work in v4.4)

    -- Lucian
     
  40. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Hi there! Is it possible to make horizontal slider, when elements positions to each other like this, and on scroll they animate from background to foreground?
     
  41. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hi!

    Not a builtin method available yet.

    No1 requirement: Canvas' Screen space shouldn't be Overlay, because you'll use the z position to change the sorting order.
    Otherwise, you also need to manage the item's order in hierarchy via SetSiblingIndex, to change their sorting method, which is fine and doesn't interfere with OSA. You could put OSA in its own Camera-space Canvas which is not nested within the main Canvas, if you want your other UI elements to be kept in the existing Overlay Canvas.

    You can manipulate the position of an item views (not the item itself, represented by the root property, because its position is dictated by OSA) in Update.
    Code (CSharp):
    1. for .. _VisibleItemsCount
    2.   var vh = GetItemViewsHolder(i);
    3.   vh.movingView.localPos = <do your own calculations here and decide X position and Z position (for seeing some items on top of anothers)>
    Having the gallery effect on, you'll use each item's localScale.x (or y, z - they're the same value) to know how "focused' an item will be, 1 meaning full and k being none, k being <1 - gallery effect amount>.
    Ask for more info, if something is not clear

    -- Lucian
     
    justtime likes this.
  42. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hello to anybody that watches this thread.
    Does anyone use the Playmaker integration? Or know someone that uses it?
    I'm planning to release OSA 5 very soon and I'd rather drop support for Playmaker if like less than 5% of users need it.
    So far, I had literally zero emails/posts with questions about it, which makes me believe no one actually uses it.
    I've put a great deal of work in it and each major update of the pack requires significant time to update the Playmaker integration, and I'm not quite sure if it's still worth it.
    Any input from you would be of great help.

    -- Lucian
     
  43. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    OSA 5 is now alive!
    And it still includes Playmaker support!
     
  44. sp-sergio-gil

    sp-sergio-gil

    Joined:
    Mar 5, 2014
    Posts:
    45
    Hi!

    I'm checking new OSA 5 and it has a lot of changes/improvements!!! thanks for that!

    I'm trying to replicate the grid with subcategories example and as I can see it works having the categories and the cell elements in each cell group prefab, and then we activate/deactivate what we want to show... It could be posible that each cell group prefab have only the elements that we need like for example if we need to show a category row then have only the HeaderPanel, and if it's a grid elements we have all the needed cellprefabs??

    This way is kinda complicated to check what's happening. Pehaps we can have two diferent cellgroupprefab (as the example with different prefabs) ans could be easy to use?

    Thanks

    Sergi
     
  45. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hi,

    Thanks! We've really made progress with OSA so far. There's almost anything you'll ever need.

    About your question, now. What's for sure, it'd be pretty hard to manage 2 prefabs in that example, but not impossible.
    This is more of a general rule, but the more prefab types you have, the more GCs you'll get and potentially FPS hiccups. Though in OSA 5, you can get around any GC by setting a high RecycleBinCapacity or always returning false in ShouldDestroyRecycleableItem().
    The way it's implemented in the demo achieves really high FPS, but I didn't think about/test any case where activating/de-activating objects would be more costly than managing 2 separate prefabs. I just had to choose one at the moment of implementation and the current one was 10x simpler (so easier to understand for those who want to replicate the demo), and I'm inclined to think it's faster.
    Do you have any particular details on why this would be better for your project, or it's more about personal preference?

    -- Lucian
     
  46. sp-sergio-gil

    sp-sergio-gil

    Joined:
    Mar 5, 2014
    Posts:
    45
    Well the thing is that I think that is much more clearer to have different prefabs that instead of having one and showing/hidding stuff on it... As my personal experience is easy to understand and manipulate later.

    In your example you have only 2 types of prefabs (category + grid cells) but if we had more and more this keeps being complicated...

    A part you provide the example but for me is not enough readable to understand whats really happening there. In this case do you think that having the same example with different prefabs could be x10 much more complicated?? I assume that doing this needs to be easy enough if not then too much work needs to be done.

    In this case I'm not thinking in FPS and performance.
     
  47. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Totally agree, and if you'll open the 2 examples demonstrating multiple prefabs use, that's exactly how it works.

    In this particular case, I'm already abstracting the headers & cells into separate elements visually, but they internally represent rows of items, because that's what a GridAdapter (the base class) requires, and thus I needed to include placeholder cells in the rows containing the headers. This already adds a level of complexity that I think it's enough for just one example scene.

    Well, the main focus of OSA is to achieve the highest FPS possible, while also covering most of the types of ScrollViews that users will ever need. Thus, if some of the included demos aren't as elegantly implemented as I'd like them to be, it's because it'd impact performance. Though most of the demos are pretty modularized and clean.

    The "grid with subcategories" is intended for simpler cases than the one you describe. Perhaps your use-case would be better implemented with another approach? Maybe "nested ScrollViews" or "nested ScrollViews same direction", possibly combining with concepts from "multiple prefabs"?

    I'd like to know the particular details on what do you want your ScrollView to do and I could then better frame it in terms of the available demos.

    -- Lucian
     
  48. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    First, sorry for the long post, but I've tried to describe the problems and how to reproduce them the best I could.

    I have found some bugs related to the resizing of the elements.
    First, some bugs in the example, and after that, some bugs with the core of OSA itself.

    Bugs in the 'Example' scene:
    In the 'example' window, if you increase the size of element 2 and very fast you scroll down using the mousewheel in order to hide the element 2 before it has finished to resize, then element 2 will be partially resized and another element will be completely resized.
    I understand that the element 2 stop resizing because it is not visible anymore, but it is not normal than another element is resized in its place.


    Bugs in the core of OSA:
    I have used my own code in order to manage the resizing of elements even when their aren't visible anymore, and I am facing a very strange situation.
    When I use RequestChangeItemSizeAndUpdateLayout() to expand a visible element, then I see the element expanding correctly.

    When I use RequestChangeItemSizeAndUpdateLayout() to expand a not visible element which is above the current view, then I see the elements in the view scrolling down as they should, but the elements on the top part of the content window aren't visible.
    They become visible after a second, but not always, most of the time I miss 3-4 elements on top, here is the final result after the resizing is completely finished:


    When I use RequestChangeItemSizeAndUpdateLayout() to expand a not visible element which is below the current view, the the view scrolls down, as if I had expanded an element above the view.
    And this time, there's no missing elements on top.

    Here are the steps to reproduce the problem using your own examples:
    Preparation:
    - open the 'example' scene
    - in the 'MainExample' class, add the following code:
    Code (CSharp):
    1. public void OnClick()
    2. {
    3.     RequestChangeItemSizeAndUpdateLayout(200, 2000.0f);
    4. }
    - add a button in the scene
    - link the 'OnClick' event to the 'OnClick()' method we just added

    Bug 1:
    - start the scene
    - center the element 30 in the scrollview
    - press the button
    - observe that element 30 isn't in the view anymore, the visible elements are before 30 (I have element 10 centered). Expected behaviour: the view must not move
    - exit the scene

    Bug 2:
    - start the scene
    - center the element 5000 in the scrollview
    - press the button
    - observe that no elements are visible, the scrollview appear empty. Expected behaviour: the view must be full of elements. Note that sometimes it works, you may have to try with other values (higher than 250)
    Note that if you scroll a bit using the mousewheel, the elements will re-appear and be consistent with the excepted scrolling
    Also, if you look into the editor view, you'll see that the 'ComplexItemPrefab' are teleported below, way out of the screen. If you scroll down using the mousewheel, then the elements will go up at the normal rate. If you scroll up just once, they will instantly go back where they should be.

    Bug 3:
    - start the scene
    - press the button without having scrolled (the element 0 should be visible)
    - observe that all the elements briefly disappear and come back scrolling smoothly
    - also observe that the bottom of the scrollbar is briefly moved to the right (it's displayed in diagonal for about 0.2s)
    Expected behaviour: nothing moves
     
  49. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    When ScrollView is resized, all the items revert to their default height.
    Steps to reproduce the problem:
    - untick 'Maximize On Play'
    - start the 'exemple' scene
    - expand an item
    - select the 'MyScrollView-Vertical' object
    - resize it a bit
    - observe that the expanded element has returned to its default height. Expected behaviour: the expanded element should have stayed expanded

    From what I saw, the 'Refresh(false, true);' line in the 'OSA.MyUpdate()' method is resetting all the the heights to the standard one before setting the sized of the ViewHolders.
     
  50. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey,

    Thank you for such a detailed bug report. I'd also like to know your OSA version and Unity version.

    RequestChangeItemSizeAndUpdateLayout didn't behave as you describe last time I've tested it on non visible items. I guess this is an edge case (although it doesn't appear to be).
    Next week the vacation ends, and I'll dive into all issues you describe. Will reply to you here when done.
    Thanks again!

    -- Lucian