You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm using this script in my project, but there is a small performance problem when updating the list, because when I update the list I need to call the function _recyclableScrollRect.ReloadData(); however from what I saw the script recreates the pooling when it calls this function in the InitCoroutine routine, is there any way to update the list without having to recreate the pooling? because in theory the items that are in the pooling are already of the same type so there is no need to instantiate again
I will leave the script of one of the screens where I use the script as an example
`using System.Collections.Generic;
using UnityEngine;
using PolyAndCode.UI;
public class StashDialog : MonoBehaviour, IRecyclableScrollRectDataSource
{
[SerializeField]
RecyclableScrollRect _recyclableScrollRect;
public Canvas Canvas;
private List<SlotItemInfo> _list = new List<SlotItemInfo>();
public bool Opened = false;
void Start()
{
if (_recyclableScrollRect != null)
_recyclableScrollRect.DataSource = this;
gameObject.SetActive(false);
Opened = false;
ItemContainerManager.StashContainer.Added += (uint itemId, ItemReference itemReference) => Refresh();
ItemContainerManager.StashContainer.Removed += (uint itemId, ItemReference itemReference) => Refresh();
ItemContainerManager.StashContainer.Cleared += () => Refresh();
ItemContainerManager.StashContainer.WeightChanged += (uint itemId) => Refresh();
}
public void Refresh()
{
if (Opened)
{
List<SlotItemInfo> list = new List<SlotItemInfo>();
foreach (var item in ItemContainerManager.StashContainer.ItemsMapping)
{
list.Add(new SlotItemInfo()
{
itemRef = item.Value,
canvas = Canvas
});
}
_list = list;
if (_recyclableScrollRect.isActiveAndEnabled)
_recyclableScrollRect.ReloadData();
}
}
public int GetItemCount()
{
return _list.Count;
}
public void SetCell(ICell cell, int index)
{
var item = cell as SlotItem;
item.ConfigureCell(_list[index], index);
}
public void Show()
{
gameObject.SetActive(true);
WindowManager.Instance.HideInventoryComplement();
if (WindowManager.Instance.TradeDialog.Opened)
WindowManager.Instance.TradeDialog.Close();
Opened = true;
Refresh();
}
public void Close()
{
_list.Clear();
gameObject.SetActive(false);
Opened = false;
}
}
`
The text was updated successfully, but these errors were encountered:
Hello, I'm using this script in my project, but there is a small performance problem when updating the list, because when I update the list I need to call the function _recyclableScrollRect.ReloadData(); however from what I saw the script recreates the pooling when it calls this function in the InitCoroutine routine, is there any way to update the list without having to recreate the pooling? because in theory the items that are in the pooling are already of the same type so there is no need to instantiate again
I will leave the script of one of the screens where I use the script as an example
`using System.Collections.Generic;
using UnityEngine;
using PolyAndCode.UI;
public class StashDialog : MonoBehaviour, IRecyclableScrollRectDataSource
{
[SerializeField]
RecyclableScrollRect _recyclableScrollRect;
}
`
The text was updated successfully, but these errors were encountered: