Class ShapeComponent
Draws a flat shape at this entity's world transform through a ShapeBatch, so shapes
take part in Stride's component system - scripts, hierarchy, enable and disable - without needing
a model or a material. Nothing else is required: where the game called AddShapeBatch() the
shape draws through that batch, and otherwise through a depth-tested one the processor registers
for itself, which is also how the shape shows in Game Studio's scene editor.
[DefaultEntityComponentProcessor(typeof(ShapeProcessor), ExecutionMode = ExecutionMode.All)]
[DataContract("ShapeComponent")]
[Display("Shape", null, Expand = ExpandRule.Once)]
[ComponentCategory("Rendering")]
public sealed class ShapeComponent : ActivableEntityComponent, IIdentifiable
- Inheritance
-
ShapeComponent
- Implements
- Inherited Members
Remarks
The entity's world matrix places the shape: its X and Y axes become the plane the shape lies in, so a rotated entity carries the shape into 3D, and the length of the X axis is taken as a uniform scale. In a 2D scene, where entities only ever rotate about Z, this is just position and rotation.
Shapes submitted this way draw before manual ShapeBatch calls made later in the same frame.
Fields
Inherit
Assigned to BorderWidth, FillAlpha or GlowWidth to take the batch's value instead of one set here. A negative width or fill is meaningless, which is what makes it a safe sentinel - and Game Studio's property grid cannot edit a nullable value type at all, so an optional float has to be expressed this way rather than as float?.
public static readonly float Inherit
Field Value
Properties
Batch
The batch this shape draws through, or null to use the game's default - the first one
registered with AddShapeBatch().
[DataMemberIgnore]
public ShapeBatch? Batch { get; set; }
Property Value
Remarks
Set this whenever a scene has more than one batch and the shape must land in a particular one. Library code especially cannot assume anything about the default: it is whichever batch the host game happened to register first, which may well be depth-tested, and a marker that must never be occluded would then silently disappear behind scene geometry.
Billboard
Whether the shape faces the camera instead of lying in the entity's own plane. The entity's rotation and scale are ignored when this is set; only its position is used.
public bool Billboard { get; set; }
Property Value
BorderWidth
Outline width in on-screen pixels for this shape, or Inherit to use the batch's BorderWidth.
public float BorderWidth { get; set; }
Property Value
Color
The outline colour; the fill derives from it unless FillColor is set.
public Color Color { get; set; }
Property Value
FillAlpha
Fill intensity for this shape, 0 to 1, or Inherit to use the batch's Alpha. Set 0 for an unfilled outline.
public float FillAlpha { get; set; }
Property Value
FillColor
The fill's own colour for this shape. Leave it fully transparent - an alpha of zero, which is the default - to use the batch's Color, which itself defaults to filling with the outline colour. For a see-through fill use FillAlpha rather than a transparent colour here.
public Color FillColor { get; set; }
Property Value
GlowColor
The glow's colour for this shape. Leave it fully transparent - an alpha of zero, which is the default - to use the batch's Color, which itself defaults to the outline colour.
public Color GlowColor { get; set; }
Property Value
GlowWidth
Width of a soft glow outside this shape's outline, in on-screen pixels, or Inherit to use the batch's Width. Set 0 for none.
public float GlowWidth { get; set; }
Property Value
Pickable
Whether the shape answers TryPick(Vector2, out ShapeHit, float): the hit's Tag is then this component, and its entity one step away. Off by default.
public bool Pickable { get; set; }
Property Value
Radius
Optional rounding radius added around the outline, in world units.
public float Radius { get; set; }
Property Value
Vertices
The shape outline in local space, counter-clockwise, at most 8 corners. May be swapped or edited at runtime; the next frame draws the new outline. A single vertex with Radius set draws a circle; two vertices with a radius draw a capsule.
public List<Vector2> Vertices { get; set; }
Property Value
Remarks
A list rather than an array on purpose: Game Studio's property grid can add to and remove from a list, and the asset serializer can load one of any length, whereas an array is shown read-only and loads only into an instance of exactly its size.