Game.Prefabs.NetSubObjectInfo
Assembly:
Assembly-CSharp (game runtime assembly that contains game types)
Namespace:
Game.Prefabs
Type:
class
Base:
System.Object
Summary:
A serializable data container describing a sub-object entry used by a network (Net) prefab. Instances specify which object prefab to place relative to a NetObject, its local transform (position & rotation), placement rules and several boolean constraints that control when and how the sub-object is spawned. This type is typically embedded in Net object prefab definitions to define decorative or functional sub-objects (e.g., signs, lamps, anchors) that attach to road/track network pieces.
Fields
-
public ObjectPrefab m_Object
Reference to the object prefab to instantiate as the sub-object. This typically points to a prefab entry (building, prop, or other in-game object) that will be placed relative to the parent NetObject. -
public float3 m_Position
Local position offset (Unity.Mathematics.float3) of the sub-object relative to the NetObject origin. Uses the game coordinate convention for net sub-objects. -
public quaternion m_Rotation
Local rotation (Unity.Mathematics.quaternion) applied to the sub-object relative to the NetObject orientation. -
public NetObjectPlacement m_Placement
Placement rule selector that determines where along the net piece the sub-object is allowed to appear (for example, at nodes, segments, evenly spaced along a segment, etc.). See NetObjectPlacement enum for possible values. -
public int m_FixedIndex
Index used when placement is at specific fixed positions (e.g., fixed attachment points). A value of -1 typically means not used. -
public float m_Spacing
Distance or spacing value used for repeated placement along a segment (e.g., distance between repeated sub-objects when placement mode requires spacing). -
public bool m_AnchorTop
If true, this sub-object should anchor to the top side of the net element (semantic meaning depends on the net; e.g., top of an elevated segment). -
public bool m_AnchorCenter
If true, anchor the sub-object to the center line/center of the net element. -
public bool m_RequireElevated
If true, the sub-object will only be placed when the parent net section is elevated (not at ground level). -
public bool m_RequireOutsideConnection
If true, the sub-object requires an outside connection (for example, only place when the net piece connects to an external network). -
public bool m_RequireDeadEnd
If true, the sub-object will only be placed at dead-end net pieces (no continuation on one side). -
public bool m_RequireOrphan
If true, the sub-object will only be placed when the net piece is orphaned (no valid network connection according to game logic).
Properties
- This type does not expose any properties (only public fields). It is a simple POD-style (plain-old-data) container intended for serialization in prefab data.
Constructors
public NetSubObjectInfo()
Default parameterless constructor is generated by the compiler. Use it to create an instance and then assign fields as needed. The class is marked [Serializable], so instances are typically deserialized from prefab data rather than constructed manually at runtime.
Methods
- This class does not declare any methods. It only stores serialized configuration data used by the net prefab spawning/placement system.
Usage Example
// Example: create and configure a sub-object entry for a net prefab
using Unity.Mathematics;
using Game.Prefabs;
var sub = new NetSubObjectInfo();
sub.m_Object = someObjectPrefabReference; // assign a valid ObjectPrefab reference
sub.m_Position = new float3(0f, 0.5f, 0f);
sub.m_Rotation = quaternion.EulerXYZ(new float3(0f, math.PI / 2f, 0f));
sub.m_Placement = NetObjectPlacement.Segment; // example enum value
sub.m_FixedIndex = -1;
sub.m_Spacing = 5.0f;
sub.m_AnchorTop = false;
sub.m_AnchorCenter = true;
sub.m_RequireElevated = false;
sub.m_RequireOutsideConnection = false;
sub.m_RequireDeadEnd = false;
sub.m_RequireOrphan = false;
// Typically this NetSubObjectInfo would be added into a list on the parent NetObject prefab.