Upgrade InventoryPropertyDrawer to UxmlSerializedDataPropertyDrawer#22
Open
alexandredzi wants to merge 7 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PropertyDrawerbase class withUxmlSerializedDataPropertyDrawer, which handles serialized object binding automaticallyCreatePropertyGUIwithCreateChildPropertiesGUI(VisualElement container, SerializedProperty property)m_InventoryPropertyandm_ItemsProperty; passSerializedPropertyexplicitly to all helper methods insteadroot.Bind(property.serializedObject)call (handled by the base class)Test plan
Characterelement in the Unity EditorCharacterelement in the Hierarchy window🤖 Generated with Claude Code