Game.Prefabs.NetPieceObjectInfo
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: System.Object
Summary:
Serializable data container used by net-piece prefabs to describe an object instance that can be placed along a network piece (road/track/bridge). Describes the prefab to spawn, its local transform offsets, placement requirements, probability and spacing rules. This class is intended to be serialized in prefab data and consumed by the net-piece placement/decoration logic at runtime or by editor/tools that build network prefabs.
Fields
-
public ObjectPrefab m_Object
Reference to the object prefab to instantiate/paint on the net piece. This typically points to a reusable object prefab (prop, decorative mesh, light, etc.) defined elsewhere. Required for the object to be placed. -
public float3 m_Position
Local position (float3, Unity.Mathematics) for the object relative to the net piece coordinate space. Units are in game world units (meters). Use this to shift the object along/above the segment or node. -
public float3 m_Offset
Additional local offset applied when placing the object. Often used for small randomization or fine adjustments relative to m_Position. -
public quaternion m_Rotation = quaternion.identity
Local rotation (quaternion, Unity.Mathematics) applied to the object. Defaults to identity (no rotation). Use to orient the object relative to the net piece. -
public NetPieceRequirements[] m_RequireAll
Array of requirements that must all be satisfied for the object to be allowed on a given placement. Each element is a NetPieceRequirements entry (see NetPieceRequirements definition) that encodes conditions such as minimum slope, lane presence, terrain flags, or other constraints. -
public NetPieceRequirements[] m_RequireAny
Array of alternative requirements; at least one of these must be satisfied for placement to proceed. Useful for allowing the object under multiple acceptable conditions. -
public NetPieceRequirements[] m_RequireNone
Array of exclusion requirements; if any of these are satisfied the object will be prevented from being placed. Use to block placement on incompatible segments or contexts. -
[Range(0f, 100f)] public int m_Probability = 100
Chance (percentage, 0–100) that the object will be placed when other conditions are met. Defaults to 100 (always). Use to randomize decoration density. -
public float m_MinLength
Minimum length of the segment (or placement span) required for this object to appear. Prevents placing objects on very short pieces. -
public float2 m_CurveOffsetRange
Range (min,max) of random curve offset along the segment when placing the object. Represented as a float2 (Unity.Mathematics). Useful to jitter placement sideways along curved segments. -
public float3 m_Spacing
Spacing vector describing placement spacing. Commonly used to define distances between repeated instances along the segment and between lanes/positions. Interpretation depends on net-piece placement code; typically X is along-segment spacing, Y/Z for lateral offsets or other axes. -
public float2 m_UseCurveRotation = new float2(0f, 1f)
Two-component range that controls how much the segment/curve rotation affects the object's final rotation. Values are typically treated as a min/max lerp factor between not using curve rotation (0) and fully aligning to curve (1). Defaults to (0,1) meaning full usage allowed. -
public bool m_FlipWhenInverted
If true, automatically flip/or adjust the object when the net piece is inverted (e.g., segment direction reversed) so the object appears correct when piece orientation changes. -
public bool m_EvenSpacing
If true, enforce even spacing of repeated objects along the segment length instead of placing them via simple step spacing. Useful for symmetrical decorations. -
public bool m_SpacingOverride
When true, this object's m_Spacing overrides any default or inherited spacing rules from the net piece. Use to force custom spacing for this object type.
Properties
- This class does not define any C# properties; it only contains public fields used for serialization.
Constructors
public NetPieceObjectInfo()
Default parameterless constructor generated by the compiler. Instances are typically created by the prefab serializer or by tools/editors. All fields use their declared default values (e.g., m_Rotation = quaternion.identity, m_Probability = 100, m_UseCurveRotation = (0,1)).
Methods
- This class does not declare any methods. All logic that interprets these fields lives in the net-piece placement/decoration systems that consume this data.
Usage Example
using Unity.Mathematics;
using Game.Prefabs;
// Create and customize a placement entry in code (also works when loaded from serialized prefab data)
var objInfo = new NetPieceObjectInfo
{
m_Object = someObjectPrefabReference,
m_Position = new float3(0f, 0.5f, 0f), // half a meter up from the piece
m_Offset = new float3(0.2f, 0f, 0f), // small lateral offset
m_Rotation = quaternion.EulerXYZ(new float3(0f, math.radians(90f), 0f)),
m_Probability = 50, // 50% chance to appear
m_MinLength = 10f, // only on segments >= 10m
m_CurveOffsetRange = new float2(-0.5f, 0.5f),
m_Spacing = new float3(5f, 0f, 0f), // attempt ~5m along-segment spacing
m_UseCurveRotation = new float2(0f, 1f),
m_FlipWhenInverted = true,
m_EvenSpacing = true,
m_SpacingOverride = true
};
// The net-piece placement system will evaluate the requirement arrays (m_RequireAll/Any/None),
// probability and spacing when deciding whether and where to instantiate m_Object along a segment.