Class ScyllaBoxShape
Parametric box (rectangular cuboid) shape with independent width / height / depth and six hard-edged faces. Covers the use cases of both a uniform cube (equal sides) and a general box (independent dimensions) by exposing all three dimensions as serialized parameters.
Inherited Members
Namespace: Scylla.Core.Util.Geom
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/Geometry/Box")]
public sealed class ScyllaBoxShape : ScyllaShapeBase3D
Remarks
The mesh is generated with 24 vertices and 36 indices (6 faces × 4 vertices each)
so face normals are flat per face. Texture coordinates are emitted as
(0,0)..(1,1) per face, suitable for planar UV-mapped textures.
When ColliderMode is set to MatchingPrimitive, a UnityEngine.BoxCollider sized to match Width, Height, and Depth is attached in place of a mesh collider.
Properties
Depth
Box size along the Z axis (world-space depth). Values below 0.0001 are
clamped when set and at build time. Setting this triggers an immediate mesh rebuild
and updates Size.
Declaration
public float Depth { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Height
Box size along the Y axis (world-space height). Values below 0.0001 are
clamped when set and at build time. Setting this triggers an immediate mesh rebuild
and updates Size.
Declaration
public float Height { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Size
Box extent as a Size3D. Components below 0.0001 are clamped
when set and at build time. Setting this triggers an immediate mesh rebuild. The
Width, Height, Depth accessors below are thin shorthand for Width /
Height / Depth of this field.
Declaration
public Size3D Size { get; set; }
Property Value
| Type | Description |
|---|---|
| Size3D |
Width
Box size along the X axis (world-space width). Values below 0.0001 are
clamped when set and at build time. Setting this triggers an immediate mesh rebuild
and updates Size.
Declaration
public float Width { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
Build(Mesh, float, float, float, IFaceColorResolver)
Populates target with a parametric box mesh sized to
width × height × depth.
Existing mesh data is overwritten. The caller is responsible for calling
UnityEngine.Mesh.RecalculateBounds() if the mesh is meant to be rendered.
Declaration
public static void Build(Mesh target, float width, float height, float depth, IFaceColorResolver resolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | Destination mesh. Must be non-null. |
| float | width | Size along the X axis. Clamped to a minimum of |
| float | height | Size along the Y axis. Clamped to a minimum of |
| float | depth | Size along the Z axis. Clamped to a minimum of |
| IFaceColorResolver | resolver | Optional per-face color resolver. When non-null, a per-vertex color channel is emitted with one solid color per face (face order: +Z, -Z, +Y, -Y, +X, -X), so the six faces can each take a distinct palette color. When null, no color channel is written. |
BuildMesh(Mesh)
Subclass extension point: write vertex / triangle / normal / uv data into
target from the shape's serialized parameters. The base class
calls Clear(bool) before invoking this method and
UnityEngine.Mesh.RecalculateBounds() afterwards, so subclasses should not invoke
either themselves.
Declaration
protected override void BuildMesh(Mesh target)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | The owned mesh to populate. Already cleared by the base class. |
Overrides
GetMeshName()
Returns the shape's mesh name as it should appear on the generated mesh asset. Defaults to the subclass type name; override to provide a friendlier label.
Declaration
protected override string GetMeshName()
Returns
| Type | Description |
|---|---|
| string | A short identifier for the generated mesh, used as UnityEngine.Object.name. |
Overrides
TryAttachPrimitiveCollider()
Subclass extension point: when ColliderMode is
MatchingPrimitive, obtain the appropriate primitive
collider through GetOrAddManagedCollider<T>(), size it to the current
parameters, and return true. Return false to let the base class fall
back to UnityEngine.MeshCollider.
Declaration
protected override bool TryAttachPrimitiveCollider()
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
Remarks
Runs on every rebuild. Always go through GetOrAddManagedCollider<T>()
rather than AddComponent: it reuses the collider from the previous rebuild,
so the override only has to update its size and center. A collider added directly
is not tracked by the shape and a new one would be added on every rebuild.