全站通知:

Modding/Inventory/Item menu builders

阅读

    

2023-12-14更新

    

最新编辑:丸丸辣

阅读:

  

更新日期:2023-12-14

  

最新编辑:丸丸辣

来自UnturnedWIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

模板:Guide

Several of the inventory item widgets are designed to very easily extendable and customizable:

Common

All custom menu buildables share a function you should override called ShouldIncludeForItem. This determines whether your menu content is eligible for building details/actions/etc for an item instance.

When your menu buildable's Create and CreateWidget functions are called they receive an InBuilder parameter. You should use this to register your built menu contents. For example an action builder has BuildAction and BuildActionWidget functions allowing you to build as many or as few as you need.

At-A-Glance Synopses

At-a-glance overlays are shown on top of item icons to quickly convey critical information. The number remaining charge in a battery, the number of bullets in a stack, and the amount of ammunition in a firearm or magazine are all examples of critical information that could be conveyed with an at-a-glance overlay.

You can create your own by subclassing UInventoryItemAtAGlanceMenu_SynopsisBase, and widget subclasses of UInventoryItemAtAGlanceMenu_SynopsisWidgetBase. For very advanced cases you can specify a custom UInventoryItemAtAGlanceMenu_Builder in your UInventoryItemDataAsset.

Context Actions

文件:U4 Modding example ContextActions.png
Hovering over the "Drop" context action for the Eaglefire.

Action buttons are available when clicking on most items, and are also used to auto-perform some tasks such as dropping an item when you hold a specific key and click it. Some examples are equipping, dropping or inspecting an item.

You can create your own by subclassing UInventoryItemContextMenu_ActionBase. Most of the vanilla actions use ActionBase's helper function CreateDefaultActionWidget which creates a button with an icon and a label. For very advanced cases you can specify a custom UInventoryItemContextMenu_Builder in your UInventoryItemDataAsset.

  • Override CanPerform for actions which should still be shown as a hint of what can be done with them, but cannot currently be performed.
  • Your action's Perform method will be called when auto-performed or clicked in the menu.
  • Override CanAutoPerform to opt-in, and use a low sort order to get selected.

Sort Order

Sort order is used to rank each action's priority. The highest priority action (lowest number) is auto-performed in some cases. Use custom sort orders to insert your actions between others!

Vanilla Sort Orders
Sort Order Description
1000 Equip
1001 Dequip
5000 Pickup
5001 Drop
10000 Default

Inspector Details

文件:U4 Modding example InspectorAttachments.png
The Eaglefire's inspector details.

Inspector details are used when inspecting the 3D preview of an item. They are for the extended information about your item like stats and lore, or can be used for extra options like whether a coat should be zipped or unzipped.

You can create your own by subclassing UInventoryItemInspectorMenu_DetailsBase. For simple text details you can use DetailsBase's helper function CreateTextDetailsWidget which adds a line of text like the item's description. For very advanced cases you can specify a custom UInventoryItemInspectorMenu_Builder in your UInventoryItemDataAsset.

Vanilla Sort Orders
Sort Order Description
1000 Description
5000 Text
10000 Attachments
15000 Default
20000 Stats

模板:Navbox content (U4)