diff --git a/ECSSamples/Assets/HelloCube/1. MainThread/RotationSpeedSystem.cs b/ECSSamples/Assets/HelloCube/1. MainThread/RotationSpeedSystem.cs index a2fdcc428..6f7183087 100644 --- a/ECSSamples/Assets/HelloCube/1. MainThread/RotationSpeedSystem.cs +++ b/ECSSamples/Assets/HelloCube/1. MainThread/RotationSpeedSystem.cs @@ -3,41 +3,34 @@ using Unity.Entities; using Unity.Transforms; -namespace HelloCube.MainThread -{ +namespace HelloCube.MainThread { [RequireMatchingQueriesForUpdate] [UpdateInGroup(typeof(MainThreadGroup))] [BurstCompile] - public partial struct RotationSpeedSystem : ISystem - { + public partial struct RotationSpeedSystem : ISystem { [BurstCompile] - public void OnCreate(ref SystemState state) - { + public void OnCreate(ref SystemState state) { } [BurstCompile] - public void OnDestroy(ref SystemState state) - { + public void OnDestroy(ref SystemState state) { } [BurstCompile] - public void OnUpdate(ref SystemState state) - { + public void OnUpdate(ref SystemState state) { float deltaTime = SystemAPI.Time.DeltaTime; // Loop over every entity having a LocalToWorldTransform component and RotationSpeed component. // In each iteration, transform is assigned a read-write reference to the LocalToWorldTransform, // and speed is assigned a read-only reference to the RotationSpeed component. - foreach (var (transform, speed) in - SystemAPI.Query, RefRO>()) - { + var RORW = SystemAPI.Query, RefRO>(); + foreach (var (transform, speed) in RORW) { // ValueRW and ValueRO both return a ref to the actual component value. // The difference is that ValueRW does a safety check for read-write access while // ValueRO does a safety check for read-only access. - transform.ValueRW.Value = transform.ValueRO.Value.RotateY( - speed.ValueRO.RadiansPerSecond * deltaTime); + transform.ValueRW.Value = transform.ValueRO.Value.RotateY(speed.ValueRO.RadiansPerSecond * deltaTime); } } } } -#endif +#endif \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/Common/HelloCubeSelectorAuthoring.cs b/ECSSamples/Assets/HelloCube/Common/HelloCubeSelectorAuthoring.cs index de4dd0a88..960e04b0b 100644 --- a/ECSSamples/Assets/HelloCube/Common/HelloCubeSelectorAuthoring.cs +++ b/ECSSamples/Assets/HelloCube/Common/HelloCubeSelectorAuthoring.cs @@ -2,20 +2,14 @@ using Unity.Scenes; using UnityEngine; -namespace HelloCube -{ - public abstract class SceneSelectorGroup : ComponentSystemGroup - { - protected override void OnCreate() - { +namespace HelloCube { + public abstract class SceneSelectorGroup : ComponentSystemGroup { + protected override void OnCreate() { base.OnCreate(); var subScene = Object.FindObjectOfType(); - if (subScene != null) - { + if (subScene != null) { Enabled = SceneName == subScene.gameObject.scene.name; - } - else - { + } else { Enabled = false; } } @@ -23,39 +17,35 @@ protected override void OnCreate() protected abstract string SceneName { get; } } - public class HelloCubeGroup : ComponentSystemGroup { } + public class HelloCubeGroup : ComponentSystemGroup { + } [UpdateInGroup(typeof(HelloCubeGroup))] - public class MainThreadGroup : SceneSelectorGroup - { + public class MainThreadGroup : SceneSelectorGroup { protected override string SceneName => "HelloCube_MainThread"; } [UpdateInGroup(typeof(HelloCubeGroup))] [UpdateAfter(typeof(MainThreadGroup))] - public class JobEntityGroup : SceneSelectorGroup - { + public class JobEntityGroup : SceneSelectorGroup { protected override string SceneName => "HelloCube_IJobEntity"; } [UpdateInGroup(typeof(HelloCubeGroup))] [UpdateAfter(typeof(JobEntityGroup))] - public class AspectsGroup : SceneSelectorGroup - { + public class AspectsGroup : SceneSelectorGroup { protected override string SceneName => "HelloCube_Aspects"; } [UpdateInGroup(typeof(HelloCubeGroup))] [UpdateAfter(typeof(AspectsGroup))] - public class PrefabsGroup : SceneSelectorGroup - { + public class PrefabsGroup : SceneSelectorGroup { protected override string SceneName => "HelloCube_Prefabs"; } [UpdateInGroup(typeof(HelloCubeGroup))] [UpdateAfter(typeof(PrefabsGroup))] - public class JobChunkGroup : SceneSelectorGroup - { + public class JobChunkGroup : SceneSelectorGroup { protected override string SceneName => "HelloCube_IJobChunk"; } -} +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/Common/RotationSpeedAuthoring.cs b/ECSSamples/Assets/HelloCube/Common/RotationSpeedAuthoring.cs index db4d4b011..632005503 100644 --- a/ECSSamples/Assets/HelloCube/Common/RotationSpeedAuthoring.cs +++ b/ECSSamples/Assets/HelloCube/Common/RotationSpeedAuthoring.cs @@ -2,22 +2,17 @@ using Unity.Entities; using Unity.Mathematics; -namespace HelloCube -{ +namespace HelloCube { // An authoring component is just a normal MonoBehavior. [AddComponentMenu("HelloCube/Rotation Speed")] - public class RotationSpeedAuthoring : MonoBehaviour - { + public class RotationSpeedAuthoring : MonoBehaviour { public float DegreesPerSecond = 360.0f; // In baking, this Baker will run once for every RotationSpeedAuthoring instance in an entity subscene. // (Nesting an authoring component's Baker class is simply an optional matter of style.) - public class Baker : Baker - { - public override void Bake(RotationSpeedAuthoring authoring) - { - var data = new RotationSpeed - { + public class Baker : Baker { + public override void Bake(RotationSpeedAuthoring authoring) { + var data = new RotationSpeed { RadiansPerSecond = math.radians(authoring.DegreesPerSecond) }; AddComponent(data); @@ -25,8 +20,7 @@ public override void Bake(RotationSpeedAuthoring authoring) } } - struct RotationSpeed : IComponentData - { + struct RotationSpeed : IComponentData { public float RadiansPerSecond; } -} +} \ No newline at end of file

AltStyle によって変換されたページ (->オリジナル) /