Game.Tools.Brush
Assembly:
Assembly-CSharp (typical Unity/managed assembly; actual assembly may vary)
Namespace:
Game.Tools
Type:
struct (value type)
Base:
IComponentData, IQueryTypeParameter
Summary:
Represents a data-only ECS component that describes a "brush" used by a tool (e.g., terrain or painting tools). It stores references and parameters required to apply the brush: the tool entity, positional information (current/start/target), and brush parameters such as angle, size, strength and opacity. This struct is blittable and intended to be used with Unity's Entities (ECS) systems and queries.
Fields
-
public Entity m_Tool
Entity identifier for the tool that owns or produced this brush (e.g., the tool entity instance). Can be Entity.Null when no tool is associated. -
public float3 m_Position
Current world position of the brush center. -
public float3 m_Target
Target position for the brush (for example, where the brush is moving toward or where its effect should be applied). -
public float3 m_Start
Start position for the brush (useful for strokes or interpolating movement). -
public float m_Angle
Rotation angle of the brush in radians (or degrees depending on the consumer—check calling code). Used to orient brush shapes or direction-sensitive effects. -
public float m_Size
Brush size / radius. Unit depends on game world scale. -
public float m_Strength
Magnitude of the brush effect (e.g., intensity of terrain modification or paint). -
public float m_Opacity
Opacity or blending factor of the brush effect, typically in range [0,1].
Properties
- This type exposes no managed properties; it is a pure data struct with public fields suitable for IComponentData.
Constructors
public Brush()
(implicit default)
No custom constructors are defined; the default parameterless struct constructor is used. Initialize values via an object initializer or by setting fields directly.
Methods
- This struct declares no methods. It functions only as a container for brush-related data used by ECS systems.
Usage Example
using Unity.Entities;
using Unity.Mathematics;
using Game.Tools;
// Create and add a Brush component to an existing entity
public void CreateBrushForTool(EntityManager em, Entity toolEntity, Entity brushEntity)
{
var brush = new Brush
{
m_Tool = toolEntity,
m_Position = new float3(10f, 0f, 20f),
m_Start = new float3(9.5f, 0f, 19.5f),
m_Target = new float3(10.5f, 0f, 20.5f),
m_Angle = 0f,
m_Size = 3.0f,
m_Strength = 0.8f,
m_Opacity = 1.0f
};
// Ensure the entity has the component type, then set it
if (!em.HasComponent<Brush>(brushEntity))
em.AddComponentData(brushEntity, brush);
else
em.SetComponentData(brushEntity, brush);
}
// Example of reading/updating Brush in a SystemBase
public partial class BrushProcessingSystem : SystemBase
{
protected override void OnUpdate()
{
// Iterate over all entities with a Brush component
Entities.ForEach((ref Brush brush) =>
{
// Example: move current position slightly towards target
float3 dir = brush.m_Target - brush.m_Position;
float dist = math.length(dir);
if (dist > 0.001f)
{
float moveSpeed = 5f * Time.DeltaTime;
brush.m_Position += math.normalize(dir) * math.min(moveSpeed, dist);
}
// Modify other brush parameters as needed...
}).ScheduleParallel();
}
}