Skip to content

Commit d294028

Browse files
author
Christian Kendall
committed
Add NonUniformScale component with random value
(for real this time . . . .)
1 parent 8aded4c commit d294028

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ECSExample/Assets/Scripts/Bootstrap.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class Bootstrap : MonoBehaviour
4949
bool primaryColor = true;
5050
Random r;
5151
quaternion rQuat;
52-
float3 rPos;
52+
float3 rPos, rScale;
5353
float rLife, rSpeed;
5454
#endregion
5555

@@ -61,7 +61,7 @@ void Start()
6161

6262
// Create our Entity archetype to spawn our cubes from later
6363
cubeArch = entityManager.CreateArchetype(
64-
ComponentType.ReadWrite<Translation>(), ComponentType.ReadWrite<Rotation>(),
64+
ComponentType.ReadWrite<Translation>(), ComponentType.ReadWrite<Rotation>(), ComponentType.ReadWrite<NonUniformScale>(),
6565
ComponentType.ReadWrite<LifeTime>(), ComponentType.ReadWrite<Speed>(),
6666
ComponentType.ReadOnly<LocalToWorld>() // Needs this (is the overall transform representation) but doesn't have to be "directly" wrote to or read from
6767
);
@@ -115,6 +115,7 @@ public void SpawnCube()
115115
r = new Random((uint)UnityEngine.Random.Range(0, 1000000));
116116

117117
rPos = r.NextFloat3();
118+
rScale = r.NextFloat3(.5f, 2.0f);
118119
rLife = r.NextFloat(2, 10);
119120
rSpeed = r.NextFloat(1, 20);
120121
rQuat = r.NextQuaternionRotation();
@@ -125,6 +126,7 @@ public void SpawnCube()
125126

126127
// Set all of the entity data
127128
entityManager.SetComponentData(cubeEntity, new Translation { Value = rPos }); // This is the Starting Position
129+
entityManager.SetComponentData(cubeEntity, new NonUniformScale { Value = rScale }); // This is the Starting Position
128130
entityManager.SetComponentData(cubeEntity, new Rotation { Value = rQuat }); // This is the Starting Rotation
129131
entityManager.SetComponentData(cubeEntity, new LifeTime { Value = rLife }); // This determines how long the cube lasts
130132
entityManager.SetComponentData(cubeEntity, new Speed { Value = rSpeed }); // This is determines the rotation and movement speed

0 commit comments

Comments
 (0)