diff --git a/EntityComponentSystemSamples/ECSSamples/Assets/Advanced/Boids/Scripts/BoidSchool.cs b/EntityComponentSystemSamples/ECSSamples/Assets/Advanced/Boids/Scripts/BoidSchool.cs index 4902fc165..c68c3eefb 100644 --- a/EntityComponentSystemSamples/ECSSamples/Assets/Advanced/Boids/Scripts/BoidSchool.cs +++ b/EntityComponentSystemSamples/ECSSamples/Assets/Advanced/Boids/Scripts/BoidSchool.cs @@ -61,11 +61,13 @@ protected override void OnUpdate() Center = boidSchoolLocalToWorld.Position, Radius = boidSchool.InitialRadius }; + + //这个参数不是很明白 Dependency = setBoidLocalToWorldJob.Schedule(boidSchool.Count, 64, Dependency); Dependency = boidEntities.Dispose(Dependency); EntityManager.DestroyEntity(entity); - }).Run(); + }).Run(); //主线程执行 不會效率低吗 } } } diff --git a/EntityComponentSystemSamples/ECSSamples/Assets/Advanced/Boids/Scripts/BoidSchoolAuthoring.cs b/EntityComponentSystemSamples/ECSSamples/Assets/Advanced/Boids/Scripts/BoidSchoolAuthoring.cs index cf3547d8b..892911c85 100644 --- a/EntityComponentSystemSamples/ECSSamples/Assets/Advanced/Boids/Scripts/BoidSchoolAuthoring.cs +++ b/EntityComponentSystemSamples/ECSSamples/Assets/Advanced/Boids/Scripts/BoidSchoolAuthoring.cs @@ -22,6 +22,7 @@ public void DeclareReferencedPrefabs(List referencedPrefabs) public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { + //给鱼群的Entity加上BoidSchool组件 dstManager.AddComponentData(entity, new BoidSchool { Prefab = conversionSystem.GetPrimaryEntity(Prefab), diff --git a/EntityComponentSystemSamples/ECSSamples/Assets/HelloCube/2. IJobEntityBatch/RotationSpeedSystem_IJobEntityBatch.cs b/EntityComponentSystemSamples/ECSSamples/Assets/HelloCube/2. IJobEntityBatch/RotationSpeedSystem_IJobEntityBatch.cs index 3fe562574..a96f76ae8 100644 --- a/EntityComponentSystemSamples/ECSSamples/Assets/HelloCube/2. IJobEntityBatch/RotationSpeedSystem_IJobEntityBatch.cs +++ b/EntityComponentSystemSamples/ECSSamples/Assets/HelloCube/2. IJobEntityBatch/RotationSpeedSystem_IJobEntityBatch.cs @@ -8,6 +8,7 @@ // This system updates all entities in the scene with both a RotationSpeed_IJobChunk and Rotation component. // ReSharper disable once InconsistentNaming +//[DisableAutoCreation] 禁止自动创建 public partial class RotationSpeedSystem_IJobChunk : SystemBase { EntityQuery m_Query; @@ -42,7 +43,14 @@ public void Execute(ArchetypeChunk batchInChunk, int batchIndex) Value = math.mul(math.normalize(rotation.Value), quaternion.AxisAngle(math.up(), rotationSpeed.RadiansPerSecond * DeltaTime)) }; + } + + //其他写法 +// var chunkRotations1 +// = batchInChunk.GetChunkComponentData(RotationTypeHandle); +// batchInChunk.SetChunkComponentData(RotationTypeHandle, +// new Rotation() { Value = new quaternion(0,0,0,0) }); } } @@ -61,7 +69,8 @@ protected override void OnUpdate() RotationSpeedTypeHandle = rotationSpeedType, DeltaTime = Time.DeltaTime }; - + + //这种调度变体将每个匹配块作为单个批处理。每个块都可以并行执行, 效率很高 Dependency = job.ScheduleParallel(m_Query, 1, Dependency); } }