forked from sengeZhou/Unity3D
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【ECSLearn】 禁用自动运行system, 1 命名空间上使用[assembly: DisableAutoCreation], 该命…
…名空间下所有system都不会自动运行 2 在class上使用[DisableAutoCreation] 只能让某个system不自动运行
- Loading branch information
Showing
4 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
ECSLearn/Assets/Scripts/ECSExa/S/Sys_DissableAutoSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters