mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
fix Cannot get managed reference index with out bounds offset
This commit is contained in:
parent
198c470e7f
commit
855695ea7e
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using static DCFApixels.DragonECS.IComponentTemplate;
|
using static DCFApixels.DragonECS.IComponentTemplate;
|
||||||
|
|
||||||
@ -50,11 +51,14 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public abstract class ComponentTemplateBase<T> : ComponentTemplateBase
|
public abstract class ComponentTemplateBase<T> : ComponentTemplateBase
|
||||||
{
|
{
|
||||||
protected static TypeMeta Meta = EcsDebugUtility.GetTypeMeta<T>();
|
protected static TypeMeta Meta = EcsDebugUtility.GetTypeMeta<T>();
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
protected T component;
|
protected T component;
|
||||||
|
[SerializeField]
|
||||||
|
private byte _offset; // Fucking Unity drove me crazy with the error "Cannot get managed reference index with out bounds offset". This workaround helps avoid that error.
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
public sealed override Type Type { get { return typeof(T); } }
|
public sealed override Type Type { get { return typeof(T); } }
|
||||||
@ -66,14 +70,8 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
public override object GetRaw()
|
public sealed override object GetRaw() { return component; }
|
||||||
{
|
public sealed override void SetRaw(object raw) { component = (T)raw; }
|
||||||
return component;
|
|
||||||
}
|
|
||||||
public override void SetRaw(object raw)
|
|
||||||
{
|
|
||||||
component = (T)raw;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +84,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public abstract class TagComponentTemplate<T> : ComponentTemplateBase<T>
|
public abstract class TagComponentTemplate<T> : ComponentTemplateBase<T>
|
||||||
where T : struct, IEcsTagComponent
|
where T : struct, IEcsTagComponent
|
||||||
{
|
{
|
||||||
public override void Apply(short worldID, int entityID)
|
public override void Apply(short worldID, int entityID)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user