[BUG] Error when changing Attribute Type

WeiYiHua

Member
UIS 1.2.15

ArgumentNullException: Value cannot be null.
Parameter name: key
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <03bd9b261dff4c2b8b568aca27f561b2>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <03bd9b261dff4c2b8b568aca27f561b2>:0)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeCollection.ChangeAttributeType (Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeBase attribute, System.Type newType) (at Assets/Plugins/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeCollection.cs:486)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeBase.ChangeType (System.Type newType) (at Assets/Plugins/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeBase.cs:732)
Opsive.UltimateInventorySystem.Editor.Utility.AttributeEditorUtility.ChangeType (Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeBase attribute, System.Type newAttributeType) (at Assets/Plugins/Opsive/UltimateInventorySystem/Editor/Utility/AttributeEditorUtility.cs:202)
Opsive.UltimateInventorySystem.Editor.VisualElements.AttributeVisualElement.OnNewAttributeTypeSelection (System.Object selectedObject) (at Assets/Plugins/Opsive/UltimateInventorySystem/Editor/VisualElements/AttributeVisualElement.cs:301)

After simply checking the code, I think it should be a logic error in the following code.
UltimateInventorySystem\Scripts\Core\AttributeSystem\AttributeCollection.cs Line: 484
Code:
for (int i = 0; i < attributeFamily.Count; i++) {
    var attachedObject = attributeFamily[i].GetAttachedObject();
    if (attachedObject != null && previousAttributes.ContainsKey(attachedObject)) { continue; }

    previousAttributes.Add(attachedObject, attributeFamily[i]);
}

Fix:
Code:
for (int i = 0; i < attributeFamily.Count; i++) {
    var attachedObject = attributeFamily[i].GetAttachedObject();
    if (attachedObject == null || previousAttributes.ContainsKey(attachedObject)) { continue; }

    previousAttributes.Add(attachedObject, attributeFamily[i]);
}
 
Last edited:
Top