Inventory Scroll view bugs

Shanmukh

Member
I am using scroll view for the inventory list. for the inventory item view drawer, I used a category filter, then it got an error when I scroll the grid. if I don't use a category filter then it doesn't give the error.
error is :
Code:
MissingReferenceException: The object of type 'ItemView' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
Opsive.UltimateInventorySystem.UI.Views.ViewDrawerBase.GetViewGameObject (System.Int32 index) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Views/ViewDrawer.cs:167)
Opsive.UltimateInventorySystem.UI.Views.ViewDrawerBase.RemoveView (System.Int32 index) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Views/ViewDrawer.cs:147)
Opsive.UltimateInventorySystem.UI.Views.ViewDrawer`1[T].DrawView (System.Int32 viewIndex, System.Int32 elementIndex, T element) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Views/ViewDrawer.cs:266)
Opsive.UltimateInventorySystem.UI.Views.ViewDrawer`1[T].DrawViews (System.Int32 startIndex, System.Int32 endIndex, System.Collections.Generic.IReadOnlyList`1[T] elements) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Views/ViewDrawer.cs:238)
Opsive.UltimateInventorySystem.UI.Grid.GridGeneric`1[T].DrawInternal () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Grid/GridGeneric.cs:325)
Opsive.UltimateInventorySystem.UI.Grid.GridBase.Draw () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Grid/GridBase.cs:311)
Opsive.UltimateInventorySystem.UI.Grid.GridNavigatorBase.SetIndexInternal (System.Int32 newIndex) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Grid/GridNavigatorBase.cs:166)
Opsive.UltimateInventorySystem.UI.Grid.GridNavigatorWithScrollView.ScrollIndexChanged (System.Int32 index) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Grid/GridNavigatorWithScrollView.cs:163)
Opsive.UltimateInventorySystem.UI.CompoundElements.ScrollbarWithButtons.ScrollIndexChangedInternal (System.Int32 newValue, System.Boolean setScrollValue, System.Boolean keepOffset) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/CompoundElements/ScrollbarWithButtons.cs:119)
Opsive.UltimateInventorySystem.UI.CompoundElements.ScrollbarWithButtons.ScrollValueChanged (System.Single newValue) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/CompoundElements/ScrollbarWithButtons.cs:81)
UnityEngine.Events.InvokableCall`1[T1].Invoke (T1 args0) (at <ca496b8c93454b2f9b9924292c19379f>:0)
UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) (at <ca496b8c93454b2f9b9924292c19379f>:0)
UnityEngine.UI.Scrollbar.Set (System.Single input, System.Boolean sendCallback) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Scrollbar.cs:248)
UnityEngine.UI.Scrollbar.DoUpdateDrag (UnityEngine.Vector2 handleCorner, System.Single remainingSize) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Scrollbar.cs:347)
UnityEngine.UI.Scrollbar.UpdateDrag (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Scrollbar.cs:329)
UnityEngine.UI.Scrollbar.OnDrag (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Scrollbar.cs:388)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IDragHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:71)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:262)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)

2. for scroll view, when I use the scroll, upper items suddenly disappear, that time it causes some weird look to the scroll bar.
3. items are automatically selected from top items from the scroll bar.
4. I want to activate an item when I click on the item. but it activates when I move the cursor on the item. from the shop menu script I activate "select only with click", but it not working.
 
The first error complains about a missing reference exception. I added a null check so that should prevent the error:
Code:
/// <summary>
/// Get the View gameobject of the index.
/// </summary>
/// <param name="index">The index of the view.</param>
/// <returns>The view gameobject.</returns>
protected virtual GameObject GetViewGameObject(int index)
{
    GameObject objectToRemove = null;
    if (m_UseViewSlot) {
        if (m_ViewSlots[index] != null && m_ViewSlots[index].View != null) {
            objectToRemove = m_ViewSlots[index].View.gameObject;
        }
    } else {
        objectToRemove = m_Content.GetChild(index)?.gameObject;
    }
    return objectToRemove;
}

2) I'm not sure what could be causing this, perhaps your scrollview size does not match the ItemView size * grid size -1, exactly.

3) There should be an option on the ItemViewSlotContainerPanelBinding to choose whether you wish to select the button on open:
1636619070134.png

4) On the ItemViewSlot you can choose whether the ItemViewSlot will be selected/unselected when the mouse hovers over:
1636619146669.png

I hope that helps
 
1. if I use the filter by a category, then items order is not shorting by filled slots. there is a gap between slots.
2. it gives some log warnings.
3. scroll view is only worked by the scroll bar. I cant to scroll by items, when I drag items then scroll is not working. I am making this game for mobile devices. the scroll bar is not handy for scrolling in mobiles. I want to setup a scroll, by dragging items also. (like Scroll Rect)
 
1) You ar not filtering the grid. You are changing the ItemView Prefab to be drawn. Look carefully you changed the category inside the CategoryItemViewSet under the ItemViewDrawer section. This object is used to draw different Item View depending on the Item Category of the item

2) You are getting warnings because the ItemViewDrawer can't find a prefab to spawn to draw the Item View. It is recommended to always have one Category set to null within the CategoryItemViewSet to set the default prefab to draw when it doesn't match other categories.

For filtering you'll want to use the options under Filter & Sorters or Grid tabs (you can have filters specific to each tab):
1636706641424.png

3) I'm afraid that is not something we offer, sorry. It is very specific to mobile games, and it isn't trivial to be able to detect whether you are trying to scroll or trying to drag and drop an item.
I would recommend you try to implement this yourself such that it can act exactly like you wish. You'll need to look into replacing the GridNavigatorWithScrollbar to something custom probably.
 
thank you.
1. I set grid navigation to none, and I created a ScrollRect and give "content" refers to "Item view slot grid". its works if I drag outside of the "Item view slot". if I drag by selecting "Item view slot", it doesn't allow me to drag on it. it blocks to dragging.
2. if the selected item is out of viewport in ScrollRect, if I select anywhere then it comes into the inside of viewport.
I requested you to try with ScrollRect.
I have ScrollRect is more use cases than Built-in grid navigations in UIS.
 
Last edited:
hi, any update on "item view slot grid" on scrollrect?.
because I can't drag by selecting "Item view slot". it blocks to drag.
 
As I mentioned in my previous reply, itemViewSlot grid on scrollrect is not something we offer and unfortunatly we do not have plans of supporting it. I'm afraid you will need to implement this solution yourself.
 
Ok. i can implement. but "Item view slot" blocks to drag. without changing this script, it is impossible to implement with scrollrect. please give the option to doesn't interact with drag.
 
I'm not sure I understand you question. An ItemViewSlot, like any button, is interactable using the Unity UI Raycast (Selectable) system.
By setting the ItemViewSlot IsInteractable to False or any child image (including images in the ItemViews) to Raycast Target False should prevent you from interacting with the ItemView at all.
1638543495275.png

If that's not enough it is always a possibility to create a custom class that inherits ItemViewSlot and override any functionality related to drag/drop.

I hope that helps
 
Top