Item capacity

To do this you may use Item collection restrictions

Here is the documentation:

Here is a video tutorial where I go through setting that up:

The idea is to set the capacity on the item definition/category as an attribute and then tell the inventory it should not add the item if it goes over a certain capacity using an Item restriction.

You may also choose whether to keep the item in your inventory or swap it out if it overloads. And you may choose what happens to the item that was forced out or rejected using an item action.
 
Got an error when creating the group item restriction and its blank in the inspector

Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.Core.InventoryCollections.GroupItemRestrictionObject.Opsive.UltimateInventorySystem.Core.IDatabaseSwitcher.IsComponentValidForDatabase (Opsive.UltimateInventorySystem.Storage.InventorySystemDatabase database) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/InventoryCollections/GroupItemRestrictionObject.cs:33)
Opsive.UltimateInventorySystem.Editor.Inspectors.DatabaseInspectorBase.DrawContent () (at Assets/Opsive/UltimateInventorySystem/Editor/Inspectors/DatabaseInspectorBase.cs:83)
Opsive.UltimateInventorySystem.Editor.Inspectors.DatabaseInspectorBase.DatabaseChanged () (at Assets/Opsive/UltimateInventorySystem/Editor/Inspectors/DatabaseInspectorBase.cs:66)
Opsive.UltimateInventorySystem.Editor.Inspectors.DatabaseInspectorBase.DrawInOrder (UnityEngine.UIElements.VisualElement parent, System.Boolean nested) (at Assets/Opsive/UltimateInventorySystem/Editor/Inspectors/DatabaseInspectorBase.cs:50)
Opsive.UltimateInventorySystem.Editor.Inspectors.InspectorBase.CreateInspectorGUI () (at Assets/Opsive/UltimateInventorySystem/Editor/Inspectors/InspectorBase.cs:32)
UnityEditor.UIElements.InspectorElement.CreateInspectorElementFromEditor (UnityEditor.Editor editor, System.Boolean reuseIMGUIContainer) (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.UIElements.InspectorElement.Reset (UnityEditor.SerializedObject bindObject) (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.UIElements.InspectorElement.ExecuteDefaultActionAtTarget (UnityEngine.UIElements.EventBase evt) (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEditor.UIElements.BindingExtensions.SendBindingEvent[TEventType] (TEventType evt, UnityEngine.UIElements.VisualElement target) (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.UIElements.BindingExtensions.Bind (UnityEngine.UIElements.VisualElement element, UnityEditor.UIElements.BindingExtensions+SerializedObjectUpdateWrapper objWrapper, UnityEditor.SerializedProperty parentProperty) (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.UIElements.BindingExtensions.Bind (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedObject obj) (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.UIElements.InspectorElement..ctor (UnityEditor.Editor editor, UnityEditor.UIElements.InspectorElement+Mode mode) (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.UIElements.EditorElement.Init () (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.UIElements.EditorElement..ctor (System.Int32 editorIndex, UnityEditor.InspectorWindow iw) (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[] editors) (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.InspectorWindow.RebuildContentsContainers () (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.InspectorWindow.RedrawFromNative () (at <d0ffe769b7a34b4cac3a7cdc5c696293>:0)
UnityEditor.HostView:OnLostFocus()
 
Update

Duplicated the one here and added it to my character and it worked as expected
Assets\Opsive\UltimateInventorySystem\Demo\DemoInventoryDatabase

just can't create one by right mouse click > create > ultimate inventory system > inventory > Group Item Restriction
 
Back
Top