forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCannonBallAuthoring.cs
31 lines (27 loc) · 926 Bytes
/
CannonBallAuthoring.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Unity.Entities;
using Unity.Mathematics;
using Unity.Rendering;
using UnityEngine;
namespace Tutorials.Tanks.Step4
{
public class CannonBallAuthoring : MonoBehaviour
{
class Baker : Baker<CannonBallAuthoring>
{
public override void Bake(CannonBallAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.Dynamic);
// By default, components are zero-initialized,
// so the Velocity field of CannonBall will be float3.zero.
AddComponent<CannonBall>(entity);
// Used in Step 8.
AddComponent<URPMaterialPropertyBaseColor>(entity);
}
}
}
// Like for tanks, we are creating a component to identify the cannon ball entities.
public struct CannonBall : IComponentData
{
public float3 Velocity; // Used in a later step.
}
}