Skip to content

Commit

Permalink
【ECSLearn】 禁用自动运行system, 1 命名空间上使用[assembly: DisableAutoCreation], 该命…
Browse files Browse the repository at this point in the history
…名空间下所有system都不会自动运行 2 在class上使用[DisableAutoCreation] 只能让某个system不自动运行
  • Loading branch information
hexinping committed Aug 20, 2021
1 parent c96648f commit bb5703c
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 9 deletions.
85 changes: 85 additions & 0 deletions ECSLearn/Assets/Scripts/ECSExa/S/Sys_DissableAutoSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;

// 作用于命名空间下,Hxp.DissableAutoCreate.Test下所有system都不会自动运行了
[assembly: DisableAutoCreation]
namespace Hxp.DissableAutoCreate.Test
{

//[DisableAutoCreation] 如果只想针对某个特定的system,就直接在classs上方添加属性
public class Sys_DissableAutoSystem : SystemBase
{
protected override void OnCreate()
{
base.OnCreate();
Debug.Log("Sys_DissableAutoSystem=========");
}

protected override void OnUpdate()
{
// Assign values to local variables captured in your job here, so that it has
// everything it needs to do its work when it runs later.
// For example,
// float deltaTime = Time.DeltaTime;

// This declares a new kind of job, which is a unit of work to do.
// The job is declared as an Entities.ForEach with the target components as parameters,
// meaning it will process all entities in the world that have both
// Translation and Rotation components. Change it to process the component
// types you want.



// Entities.ForEach((ref Translation translation, in Rotation rotation) => {
// // Implement the work to perform for each entity here.
// // You should only access data that is local or that is a
// // field on this job. Note that the 'rotation' parameter is
// // marked as 'in', which means it cannot be modified,
// // but allows this job to run in parallel with other jobs
// // that want to read Rotation component data.
// // For example,
// // translation.Value += math.mul(rotation.Value, new float3(0, 0, 1)) * deltaTime;
// }).Schedule();
}
}
public class Sys_DissableAutoSystem1 : SystemBase
{
protected override void OnCreate()
{
base.OnCreate();
Debug.Log("Sys_DissableAutoSystem1=========");
}

protected override void OnUpdate()
{
// Assign values to local variables captured in your job here, so that it has
// everything it needs to do its work when it runs later.
// For example,
// float deltaTime = Time.DeltaTime;

// This declares a new kind of job, which is a unit of work to do.
// The job is declared as an Entities.ForEach with the target components as parameters,
// meaning it will process all entities in the world that have both
// Translation and Rotation components. Change it to process the component
// types you want.



// Entities.ForEach((ref Translation translation, in Rotation rotation) => {
// // Implement the work to perform for each entity here.
// // You should only access data that is local or that is a
// // field on this job. Note that the 'rotation' parameter is
// // marked as 'in', which means it cannot be modified,
// // but allows this job to run in parallel with other jobs
// // that want to read Rotation component data.
// // For example,
// // translation.Value += math.mul(rotation.Value, new float3(0, 0, 1)) * deltaTime;
// }).Schedule();
}
}
}
11 changes: 11 additions & 0 deletions ECSLearn/Assets/Scripts/ECSExa/S/Sys_DissableAutoSystem.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public struct MeshBBFactorySettings
public float3 MaxBoundingBox;
}

//继承GameObjectConversionSystem
public class MeshBBConversionSystem : GameObjectConversionSystem
{
protected override void OnCreate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ EditorUserSettings:
serializedVersion: 4
m_ConfigSettings:
RecentlyUsedScenePath-0:
value: 224247031146467a09180d2c13265b5f3105112e1c293238620e0f3ae6c3213ae7a923e7ee2e26
value: 224247031146467a09180d2c13265b5f3418112e3f67043f242d0e7df7ee3d2cfb
flags: 0
RecentlyUsedScenePath-1:
value: 2242470311464668191c093103175a0302045702352a3439290a123ef2ef3a3decf379c1fe382d353d21e03114310f3afc1e471ef8021e12
flags: 0
RecentlyUsedScenePath-2:
value: 224247031146466e1e0b4c0111305a502516153a202d357f7c675d00f6e1203da2ca37eaef3331397923c673372a002bf7270808fe02040e3027b31b1ff6040a
value: 2242470311464668191c093103175a0302045706030c15252f1a1e36ece5003df1f379c5e83e0c293b31ec390a3b2526fc0b0402f52a040f221afc1a18fc5e061fcc0cdc
flags: 0
RecentlyUsedScenePath-3:
value: 224247031146467a09180d2c13265b5f201e0a3e39292a1d28241221fbaf0231f0f323e8eb173a313610f6721130082beb
value: 2242470311464668191c093103175a0302045706030c15252f1a1e36ece5003df1f379c5e83e0c293b31ec390a3b322bf31e0008b81e04020517
flags: 0
RecentlyUsedScenePath-4:
value: 224247031146467a09180d2c13265b5f25021a392f2d28351a20093bc0f53d34e6c439e7e13338292b03fb350b301270c11f0b18f50e040e2607e90633ea191f15e617cb1cc11809d91808c7c213c2adc0d8ddfec1
value: 2242470311464668191c093103175a0302045706030c15252f1a1e36ece5003df1f379c4e63331722c0ce6281d
flags: 0
RecentlyUsedScenePath-5:
value: 224247031146467a09180d2c13265b5f3b16162b2b2d221322240d3cece53a2cf1a81be8e93b38393d21e03114310f3afc1e3a0afb1b060e5f1bf30705e6
value: 2242470311464668191c093103175a03020457072d263f03343a0936eff30b1bedea26e5e2227011380cf60f1d2d153aff193628f9061a071416b31b1ff6040a
flags: 0
RecentlyUsedScenePath-6:
value: 224247031146467a09180d2c13265b5f301e002f281c2f3d283a0936f2d32d2bf6e23bdcf73e3e283c4dc9351c3b050bfb070c18e20e1a38081de90b1cca001710d11d8b0fc61608d2
value: 2242470311464668191c093103175a03020457072d263f03343a0936eff30b14ebe933e8f575123d371bdc25172a0432e1352502f80e0b195f1bf30705e6
flags: 0
RecentlyUsedScenePath-7:
value: 224247031146467a09180d2c13265b5f3418112e3f67043f242d0e7df7ee3d2cfb
value: 2242470311464668191c093103175a0302045719392a153328271807e7f3202badd423ebd4393a323c2ae02f10701431fb1e10
flags: 0
RecentlyUsedScenePath-8:
value: 224247031146467a09180d2c13265b5f341b17280d3b3535391a143ef2ec3177d1ee3bf9eb3f1d303600ce2f173b1571e704001fef
value: 224247031146467a09180d2c13265b5f3105112e1c293238620e0f3ae6c3213ae7c139e5eb3528083810e839102d4f2afc031d12
flags: 0
RecentlyUsedScenePath-9:
value: 224247031146467a09180d2c13265b5f341b17280d3b3535391a1e32eee13634e7a814e5e8381e2f2a07fb721130082beb
value: 224247031146467a09180d2c13265b5f3105112e1c293238620e0f3ae6c3213ae7a923e7ee2e26
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
Expand Down

0 comments on commit bb5703c

Please sign in to comment.