#generic buffer method

1 messages · Page 1 of 1 (latest)

zinc mesa
#

Hello,
I have different dynamic buffer for inventories because they have different sizes. So I made an interface that I could use to write some methods that can operate on all inventories:
public interface IInventoryItem : IBufferElementData
The methog should look like this:
public static bool CanCraft<T>(DynamicBuffer<T> inventoryBuffer, Recipe recipe) where T : struct, IInventoryItem
The problem is that I get this error message:
The type 'T' must be valid unmanaged type (simple numeric, 'bool', 'char', 'void', enumeration type or struct type with all fields of unmanaged types at any level of nesting) in order to use it as a type argument for 'T' parameter

Does anyone know how to write methods for different buffers?

bright epoch