Skip to content

Upgrade InventoryPropertyDrawer to UxmlSerializedDataPropertyDrawer#22

Open
alexandredzi wants to merge 7 commits into
masterfrom
feat/upgrade-inventory-drawer-to-uxml-serialized-data-property-drawer
Open

Upgrade InventoryPropertyDrawer to UxmlSerializedDataPropertyDrawer#22
alexandredzi wants to merge 7 commits into
masterfrom
feat/upgrade-inventory-drawer-to-uxml-serialized-data-property-drawer

Conversation

@alexandredzi

Copy link
Copy Markdown

Summary

  • Replace PropertyDrawer base class with UxmlSerializedDataPropertyDrawer, which handles serialized object binding automatically
  • Replace CreatePropertyGUI with CreateChildPropertiesGUI(VisualElement container, SerializedProperty property)
  • Remove instance fields m_InventoryProperty and m_ItemsProperty; pass SerializedProperty explicitly to all helper methods instead
  • Remove manual root.Bind(property.serializedObject) call (handled by the base class)

Test plan

  • Open a UXML document with a Character element in the Unity Editor
  • Select the Character element in the Hierarchy window
  • Verify the custom inventory drawer appears in the Inspector
  • Verify the ID value is automatically assigned when adding items
  • Verify the Add Sniper Gear, Add Warrior Gear, and Add Medic Gear preset buttons work correctly
  • Verify the + button in the list footer shows a menu of all item types

🤖 Generated with Claude Code

alexandredzi and others added 7 commits April 28, 2026 17:26
Replaces the PropertyDrawer base class with UxmlSerializedDataPropertyDrawer,
which handles serialized object binding automatically. The CreatePropertyGUI
override is replaced by CreateChildPropertiesGUI, instance fields are removed,
and SerializedProperty is passed explicitly to all helper methods instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Wrap ListView in UxmlAttributeFieldDecorator so the items list
  participates in the override and binding system
- Add alignedFieldUssClassName to ammoField for correct Inspector alignment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add GunPropertyDrawer.cs and SwordPropertyDrawer.cs with item type labels
- Add GunDrawer.uxml and InventoryDrawer.uxml UXML templates
- Update InventoryPropertyDrawer.cs to showcase all four patterns
- Update AmmoPropertyDrawer.cs to build UI in C# (no UXML template)
- Update Inventory.cs with description, maxSlots, maxWeight fields
- Update HealthPack.cs (Gun) with fireRate field
- Update Sniper.uxml with new attribute values

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Cache VisualTreeAsset in a static field to avoid repeated disk lookups
- Extract AppendItem helper in InventoryPropertyDrawer to eliminate duplicated add/init logic
- Add path-dependency comment near AssetDatabase.LoadAssetAtPath calls

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace var with explicit types in AmmoPropertyDrawer, GunPropertyDrawer,
  InventoryPropertyDrawer, and SwordPropertyDrawer
- Break long IntegerField initializer lines in AmmoPropertyDrawer

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant