|
FAQ
Sept 18, 2018 20:33:31 GMT
Post by echo17 on Sept 18, 2018 20:33:31 GMT
Q: I'm having a problem, what is the best way to get help?A: answerQ: How can I make snapping only occur if the scroller is not being dragged?A: answerQ: How do I dynamically set the cell size based on the view contents?A: answerQ: Does it support grids?A: answerQ: How do I set the scroller position when reloading data? How do I keep it from jumping back to the top of the list?A: answerQ: How do I download the latest version of the asset?A: answerQ: How do I get a list of all the currently active cell views in the EnhancedScroller?A: answerQ: How can I get the cell index at a given offset of my scroller?A: answerQ: How do I use the new Unity Input System?A: answerQ: How do I prefetch cells? How do I cache more cells that what is visible for smoother transitions?A: answerQ: How do I disable dragging on the scroller to make it non-interactable?A: answerQ: Why is my scroller not scrolling smoothly?A: answer
|
|
|
FAQ
Sept 18, 2018 20:33:51 GMT
Post by echo17 on Sept 18, 2018 20:33:51 GMT
Q: I'm having a problem, what is the best way to get help?Now and then you will come across a problem or question that may not be answered in these FAQs. If so, the best way to communicate the issue with me is to create a simple project that shows the problem occurring. Being able to dig into your project and run it against my source code is the quickest way for me to see what is going on. Please include the invoice number you received when you purchased EnhancedScroller. I will only debug your projects if I can verify that you have purchased the plugin. Be sure to keep your project simple. Try to eliminate anything else that is not relevant to the problem so that it is easier to narrow down the issue. Larger projects will take more time to sift through and may introduce other errors not directly related to EnhancedScroller. If possible, create a project from scratch and build an example that produces the issue you are seeing. Also, be sure to include a list of steps that I can perform to reproduce the issue. Keep in mind that I have never seen your project before and do not know how to interact with it without your guidance. Let me know what you expect to see, since what I observe may appear operational to my uninitiated eye. Note that the more complicated your example project or the less detail you provide in how to demonstrate an issue you are seeing, the lower the priority I will assign to helping you solve your issue. Most of my time is spent helping people with my various products, so to make it fair to everyone I will choose to help those that make it easier first.When you create your project, just zip up the entire project folder. If you send me individual assets, the links between them will be lost and I will have to recreate the project from scratch. This can possibly produce skewed results since I have created a different project from the one you have sent. The best way to determine if your sample project is testable is to import it yourself into a fresh Unity project and try to run it. You can send your project to the email in my signature. I try to respond as quickly as possible (with the exception of weekends, holidays, and vacation time). Note: Please DO NOT post your project on public forums! This is a violation of the Unity Asset Store license agreement since your project will contain code which you are not free to distribute.
|
|
|
FAQ
Sept 18, 2018 20:34:25 GMT
Post by echo17 on Sept 18, 2018 20:34:25 GMT
Q: How can I make snapping only occur if the scroller is not being dragged?Note: This is now included in v2.22.0+ by default. You can disable it by turning off snapWhileDragging.You could create a simple script that controls when the snapping is turned on. You could then attach this script to the same game object that has the scroll rect. Based on Unity's documentation from these links: docs.unity3d.com/ScriptReference/UI.ScrollRect.OnBeginDrag.htmldocs.unity3d.com/ScriptReference/UI.ScrollRect.OnEndDrag.htmlThis script will control snapping based on the drag state of the scrollrect: using UnityEngine; using EnhancedUI.EnhancedScroller; using UnityEngine.EventSystems;
public class SnapController : MonoBehaviour, IBeginDragHandler, IEndDragHandler { private EnhancedScroller scroller;
void Awake() { scroller = GetComponent<EnhancedScroller>(); }
public void OnBeginDrag(PointerEventData data) { scroller.snapping = false; }
public void OnEndDrag(PointerEventData data) { scroller.snapping = true; } }
|
|
|
FAQ
Sept 18, 2018 20:35:04 GMT
Post by echo17 on Sept 18, 2018 20:35:04 GMT
Q: How do I dynamically set the cell size based on the view contents?
Check out Demo #8 included with the plugin.
|
|
|
FAQ
Sept 18, 2018 20:35:41 GMT
Post by echo17 on Sept 18, 2018 20:35:41 GMT
Q: Does it support grids?
Edit: Please look at Demo #10 included with the plugin version 2.13+ for a complete example of the explanation below
The EnhancedScroller does not support dynamic grids that can adjust the cells and rows as the scroller is resized, but you can set up a grid with a fixed number of columns (if your scroller is vertical) or a fixed number of rows (if your scroller is horizontal).
An example of how to set up a vertical scroller with a fixed number of columns:
You would need to set up your cells to handle multiple sets of data. So for instance, if you have three columns in each row, you would need to set up your cell to show three groupings of controls. You can then get the data for each subgroup by taking the cell data index and multiplying it by your column count and then adding the subgroup index. So something like:
var subGroupDataIndex = (dataIndex * columnCount) + subGroupIndex;
in the case of three columns, you can reference each subgroup inside your cell view with something like:
int subGroupDataIndex ; for (var subGroupIndex = 0; subGroupIndex < 3; subGroupIndex++) { subGroupDataIndex = (dataIndex * 3) + subGroupIndex;
// do something with your subgroup cell here }
In addition, you would need to make sure your grid's cell count is divided by the number of columns. So in the GetNumberOfCells handler, you would return
data.Count / columnCount;
The last row will likely need to hide anywhere from all-but-one subgroup to none of the subgroups. You can determine the subgroups to hide by testing if their subGroupCellIndex is greater than your data count minus 1.
|
|
|
FAQ
Sept 18, 2018 20:37:12 GMT
Post by echo17 on Sept 18, 2018 20:37:12 GMT
Q: How do I set the scroller position when reloading data? How do I keep it from jumping back to the top of the list?
The ReloadData method has an optional position parameter that you can use to set the scroller's position after loading the data. The position is normalized, meaning that 0 is the start of the list and 1 is the end.
If you want to keep the scroller's position after reloading data (assuming the cell count and cell sizes are the same):
scroller.ReloadData(scroller.NormalizedScrollPosition);
If you want to set the scroller's position based on the pixel offset:
scroller.ReloadData(pixelPosition / scroller.ScrollSize);
|
|
|
FAQ
Sept 18, 2018 20:37:56 GMT
Post by echo17 on Sept 18, 2018 20:37:56 GMT
Q: How do I download the latest version of the asset?Unity allows developers to submit assets that will work on specific versions of the Unity Editor. To ensure that you have the latest version of the asset, please upgrade your Unity Editor to the latest version before downloading / importing the asset. Sometimes Unity will not automatically show you that an asset has an update, so you will need to do a few extra steps to get the latest version. Open the Asset Store window in the Unity Editor. Click on your asset list icon: Click on the My Downloads link: Scroll to find your asset, then click the Update button. Once it is downloaded, you can then import.
|
|
|
FAQ
Sept 18, 2018 20:38:46 GMT
Post by echo17 on Sept 18, 2018 20:38:46 GMT
Q: How do I get a list of all the currently active cell views in the EnhancedScroller?
You can create a function that looks like:
public MyCellView[] GetCellViews(EnhancedScroller scroller) { var containerTransform = scroller.GetComponent<UnityEngine.UI.ScrollRect>().content.transform; return containerTransform.GetComponentsInChildren<MyCellView>(false); }
Assuming your cell view is of type MyCellView for this example.
|
|
|
FAQ
Nov 1, 2019 15:45:37 GMT
Post by echo17 on Nov 1, 2019 15:45:37 GMT
Q: How can I get the cell index at a given offset of my scroller?
The following code demonstrates how to determine what cell index is at a given offset of a scroller. The normalized position goes from zero (top or left depending on your scroll direction) to one (bottom or right). For example, the middle of the scroller would be 0.5f.
using System.Collections; using System.Collections.Generic; using UnityEngine; using EnhancedUI.EnhancedScroller;
public class GetCellIndexAtPosition : MonoBehaviour {
public EnhancedScroller scroller;
// The normalized offset from the top of the scroll rect (0..1) // For example, if you are looking for the middle of the scroller, the normalized offset would be 0.5f public float normalizedOffset = 0.5f;
void Update () { // Get the position of the scroller with the offset from the top. // This is the position of the scroller plus the offset position for where to look at the cells var midScrollPosition = scroller.ScrollPosition + (scroller.ScrollRectSize * normalizedOffset);
// get the cell view index at that position var midCellViewIndex = scroller.GetCellViewIndexAtPosition(midScrollPosition);
// output the cell view index Debug.Log(midCellViewIndex); } }
|
|
|
FAQ
Aug 4, 2020 13:49:11 GMT
Post by echo17 on Aug 4, 2020 13:49:11 GMT
Q: How do I use the new Unity Input System?There are a few steps to upgrade to the new Unity Input System. These steps are not specific to EnhancedScroller and apply to any scene that did not use the input system before. 1) Import the Input system from Package Manager 2) When you receive a warning to enable backend, click Yes3) Go into your scene and select the EventSystem game object. Find the StandAlone Input Module component and click the button that says Replace with InputSystemUIInputModule4) Find the Touch Input Module component on the same game object and remove it since it is no longer required
|
|
|
FAQ
Jan 29, 2022 11:45:28 GMT
Post by echo17 on Jan 29, 2022 11:45:28 GMT
Q: How do I prefetch cells? How do I cache more cells that what is visible for smoother transitions?
There is a look ahead feature that lets you load in cells before they are visible. You could set the look ahead to a very large value which would force it to load all cells. The look ahead is pixel based, so just use a large number of pixels to say you want to view more cells.
Something like:
scroller.lookAheadBefore = 10000f; scroller.lookAheadAfter = 10000f; scroller.ReloadData();
The lookAheadBefore "looks ahead" (meaning before loading) in the up or left direction, depending on your orientation. The lookAheadAfter looks ahead in the down or right direction. Setting both ensures that you have cells pre-loaded before and after your cell position in case the user transitions either way.
|
|
|
FAQ
Feb 6, 2022 12:16:48 GMT
Post by echo17 on Feb 6, 2022 12:16:48 GMT
Q: How do I disable dragging on the scroller to make it non-interactable?
You will need to set up a script that inherits from ScrollRect. Inside the script you would set up the drag events, but don't have any code inside them.
using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using System.Collections;
public class NoDragScrollRect : ScrollRect {
public override void OnBeginDrag(PointerEventData eventData) { } public override void OnDrag(PointerEventData eventData) { } public override void OnEndDrag(PointerEventData eventData) { } }
Instead of using the base ScrollRect from Unity, you would instead use this script in its place.
Note: if you have EnhancedScroller component already on your game object, you will need to remove this first before removing the Unity ScrollRect since the ScrollRect is a dependency for EnhancedScroller. After you have removed both EnhancedScroller and ScrollRect, you can then add the new script you created, then finally add EnhancedScroller back.
|
|
|
FAQ
Feb 20, 2022 13:20:47 GMT
Post by echo17 on Feb 20, 2022 13:20:47 GMT
Q: Why is my scroller not scrolling smoothly?
The scrolling is handled completely by Unity's ScrollRect. To enhance the smoothness, you can set this in your code:
Application.targetFrameRate = 60;
|
|