You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
492 B
21 lines
492 B
2 years ago
|
using Unity.Collections.LowLevel.Unsafe;
|
||
|
|
||
|
namespace GameCore.LowLevel
|
||
|
{
|
||
|
public static class StructUtility
|
||
|
{
|
||
|
public static int OffsetOf<T, F>()
|
||
|
where T : struct
|
||
|
where F : struct
|
||
|
{
|
||
|
var fields = typeof(T).GetFields();
|
||
|
foreach (var f in fields)
|
||
|
{
|
||
|
if (f.DeclaringType == typeof(F))
|
||
|
return UnsafeUtility.GetFieldOffset(f);
|
||
|
}
|
||
|
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
}
|