[Solved] Equipment UI tool generate grid in editor using the setting `Inventory Grid` instead of that of `Equipment`

Justus

Member
Reproduce Step:
1. Set your own custom Slot container and `Category Item View Set` for equipment
1651575405864.png

2. Generate Equipment View via UI Designer
1651575479282.png
3. The generate Item View is still same as the setting of `InventoryGrid`, in Editor <--------------------------BUG
1651575651039.png
4. if we enter Play Mode,the generated grid at runtime is same as that we have set in Equipment setting <-------------------correct
 
I see... I wouldn't really consider this a bug considering the ItemViews you see in the editor will always be replaced at runtime, so having any view doesn't change the functionality.

That being said here is a "fix" which was the less destructive to solve your issue. I'll add it to the next update:

In EquipmentDesigner.cs line 180 replace this function.
Code:
public ItemViewSlot AddItemViewSlot(RectTransform slotContainerContent)
{
    var itemViewSlot =
        UIDesignerManager.InstantiateSchemaPrefab<ItemViewSlot>(UIDesignerSchema.ItemViewSlot, slotContainerContent);
    var itemViewSlotRect = itemViewSlot.transform as RectTransform;
    var itemViewPrefab = UIDesignerSchema.EquipmentItemViewSet?.FindItemViewPrefabForItem(null)?.GetComponent<ItemView>();
    if (itemViewPrefab == null) {
        itemViewPrefab = UIDesignerSchema.ItemViewForGrid;
    }
    
    var itemView =
        UIDesignerManager.InstantiateSchemaPrefab<ItemView>(itemViewPrefab, itemViewSlotRect);
    itemViewSlot.m_ItemView = itemView;
    itemViewSlotRect.sizeDelta = (itemView.transform as RectTransform).sizeDelta;
    return itemViewSlot;
}
 
Considering this situation. You have a series Equipment grid which has different size with that in Inventory Grid. After equipment tab generate these grids, you need to tuning the position of them as your own final layout. If the grid in the Editor is that of Inventory Grid, it's hard for you to do that. So I think this is a bug.
 
I see... I wouldn't really consider this a bug considering the ItemViews you see in the editor will always be replaced at runtime, so having any view doesn't change the functionality.

That being said here is a "fix" which was the less destructive to solve your issue. I'll add it to the next update:

In EquipmentDesigner.cs line 180 replace this function.
Code:
public ItemViewSlot AddItemViewSlot(RectTransform slotContainerContent)
{
    var itemViewSlot =
        UIDesignerManager.InstantiateSchemaPrefab<ItemViewSlot>(UIDesignerSchema.ItemViewSlot, slotContainerContent);
    var itemViewSlotRect = itemViewSlot.transform as RectTransform;
    var itemViewPrefab = UIDesignerSchema.EquipmentItemViewSet?.FindItemViewPrefabForItem(null)?.GetComponent<ItemView>();
    if (itemViewPrefab == null) {
        itemViewPrefab = UIDesignerSchema.ItemViewForGrid;
    }
   
    var itemView =
        UIDesignerManager.InstantiateSchemaPrefab<ItemView>(itemViewPrefab, itemViewSlotRect);
    itemViewSlot.m_ItemView = itemView;
    itemViewSlotRect.sizeDelta = (itemView.transform as RectTransform).sizeDelta;
    return itemViewSlot;
}
This fix works well. Thank you very much!
 
Top