Open SimonDarksideJ opened 2 years ago
On 2018.05.09 00:34, Axel Luna commented: ops, i posted it as anonymous, any question im OP lol :D
On 2018.05.09 11:07, @SimonDarksideJ commented: Thanks for the detailed issue @AxelLunaB. Although in future, can you post separate issues (even if they are related) in separate issues please. A sample scene with the scripts included also helps to progress things quicker.
Issue created by <unknown> as Bitbucket Issue #237 on 2018.05.09 00:33. Hello, for understanding sake i will approach this issue on two steps. the first one being an Empty HSS without UI_InfiniteScroll and the second step including the UI_InfiniteScroll functionality
Context/Setup:
Experimental ScrollSnapBase https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/raw/4e6f14118ffe5f66ecc9bae3eb8c823922af1442/Scripts/Layout/ScrollSnapBase.cs
Empty Horizontal Scroll Snap
https://imgur.com/Ocpgbkr
2 buttons:
button#1- Instances prefab and adds it through Addchild
button#2-Deletes all Children
Issue reproduction
Click Button#1 as many times as you want, all instances will be correctly added and you can scroll through them
Click Button#2 to clear all the children.
Click Button#1 to add a new set of children and they will not be correctly positioned and/or will behave incorrectly
Issue workaround
i believe that the issue is that _currentPage and _screensContaioner.offsetMin are not being reset
added following code to HorizontalSrollSnap RemoveAllChildren(); line 175
Now you should be able to instance / delete and it will scroll as intended
Issue#2 including the UI_InfiniteScroll Script
Context/Setup:
Same as Issue#1, except that the HSS now has UI_InfiniteScroll with Init by user set to true
Button#3- toggles the Init() method of UI_IS
Button#2- added a new line
Issue reproduction
Click Button#1 as many times as you want, all instances will be correctly added and you can scroll through them
Click Button#3 to init the infinity script, and they will scroll correctly
Click Button#2 to clear all the children.
Click Button#1 to add a new set of children and click button#3 they will not be correctly positioned and/or will behave incorrectly, sometimes they dissapear, sometimes you cannot scroll through them past first and last child.
Issue Workaround
well this was a tricky one and thanks to issue #132 and @Bastiaan Hofsteenge workaround i archieved it to work.
https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/issues/132/infinitescroll-snap-script
i added a function to ui_infiniteScroll as the content object is not being reset (same as issue#1)
Now to fix the issue we need to validate when screen is 0, so it doesnt return an error
line 142 UI_InfiniteScroll
public void OnScroll(Vector2 pos) { if (!_hasDisabledGridComponents) DisableGridComponents();
Now in ScrollSnapBase line 94 we add the following
Now you can add and delete children as you like just call Init() after Removing previous Children
it may not be the best approach but hey, its something!
Scripts: https://pastebin.com/xMqua0N4 - ScrollSnapBase https://pastebin.com/hZ5cK6Ee - UI_InfiniteScroll https://pastebin.com/pLpFPcT5 - HorizontalScrollSnap https://pastebin.com/Tp3ghWxf - myCustom method used for this issue, in case its useful
Regards!