测试IJobParallelForDefer

This commit is contained in:
孙钦者 committed 2025-12-19 04:43:26 +08:00
1 parent d9b66edd89
commit 098cbfb696
4 files changed
+80 -6

No files matched your search

+20 -1
View File
@@ -22,6 +22,20 @@ namespace ECSTest.Server
// Debug.LogError($"xxxx2222 CannonData id: {componentId2}");
}
}
[BurstCompile]
public struct GetDeferred : IJob
{
public World world;
public void Execute()
{
// var componentId = ComponentId<BulletData>.Get();
// Debug.LogError($"XXXX bulletData id: {componentId}");
// var componentId2 = ComponentId<CannonData>.Get();
// Debug.LogError($"xxxx2222 CannonData id: {componentId2}");
}
}
[BurstCompile]
public struct SpawnCannonJob : IJob
@@ -33,6 +47,7 @@ namespace ECSTest.Server
public int maxCount;
public int spawnCountPerFrame;
public Rect rect;
public int initHealth;
public void Execute()
{
@@ -49,7 +64,11 @@ namespace ECSTest.Server
var velocity = new float2(c, s);
var entity = database.AddEntity();
//TODO
ref var cannonData = ref database.GetDataRef<CannonData>(entity);
cannonData.position = pos;
cannonData.velocity = velocity;
cannonData.direction = dir;
cannonData.health = initHealth;
}
}
}
-5
View File
@@ -58,11 +58,6 @@ namespace ECSTest.Server
void Update()
{
var componentId = ComponentId<BulletData>.Get();
Debug.LogError($"AAAA bulletData id: {componentId}");
var componentId2 = ComponentId<CannonData>.Get();
Debug.LogError($"AAAA2222 CannonData id: {componentId2}");
networkJobHandle.Complete();
var concurrentDriver = driver.ToConcurrent();