unity-elastic-inventory icon indicating copy to clipboard operation
unity-elastic-inventory copied to clipboard

GetAll with casting fails in some cases

Open ashblue opened this issue 1 year ago • 0 comments

When calling GetAll<T> with an item entry type (line 180). The cast will fail if you're using a custom item entry type and a custom item entry type that forks the base item entry. A LINQ cast is being made and it needs to be converted to a cast type that takes into account potential failure of the conversion.

// Add the items
inventory.Add(generic default item)
inventory.Add(new custom item entry)

// This now fails
var myCustomEntries = inventory.GetAll<MyCustomItemEntry>();

ashblue avatar May 29 '24 00:05 ashblue