Class/Struct Info |
|---|
CopyMethod(in T value, ref T target, in CopyContext context) 复制委托模板,在非blittable组件中,需要实现该方法,以支持组件的深拷贝。 当前开发者可以不手动实现CopyMethod,框架已实现默认深拷贝。 |
public struct TestCopyMethodComponent : IComponent
{
public string componentName { get; set; }
public List<int> list;
public List<TestObj> TestObjs { get; set; }
public static void CopyMethod(in TestCopyMethodComponent source, ref TestCopyMethodComponent target, in CopyContext context)
{
if (source.list == null)
{
target.list = null;
return;
}
target.list ??= new List<int>();
target.list.Clear();
target.list.AddRange(source.list);
target.TestObjs ??= new List<TestObj>();
target.TestObjs.Clear();
target.TestObjs.AddRange(source.TestObjs);
}
}