Game.Tools.ObjectDefinition
Assembly: Assembly-CSharp (game)
Namespace: Game.Tools
Type: public struct
Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
Represents an object instance definition used by the game's tools and object-placement systems. This ECS component stores transform information (world and local position/rotation), scale, and several metadata fields used by placement/spawning/rendering systems (e.g., elevation, intensity, age, parent mesh/indexing and probability/sub-prefab selection). It is a plain data component (IComponentData) intended to be attached to entities and used in queries and jobs.
Fields
-
public float3 m_Position
World-space position of the object. -
public float3 m_LocalPosition
Local position relative to the object’s parent or parent mesh. -
public float3 m_Scale
Scale of the object (per-axis). -
public quaternion m_Rotation
World-space rotation as a quaternion. -
public quaternion m_LocalRotation
Local rotation relative to the parent. -
public float m_Elevation
Elevation value (height offset) used for placement; typically measured in world units. -
public float m_Intensity
A float used as a weighting or intensity value (e.g., placement/density strength, LOD factor, or visual intensity depending on consumer). -
public float m_Age
Age of the object (seconds or game-time units). Can be used for lifecycle, growth, or fade logic. -
public int m_ParentMesh
Index or identifier of the parent mesh or parent entity slot. Used to associate this object with a parent mesh container. -
public int m_GroupIndex
Grouping index for organization (batching, grouping in tools or editors). -
public int m_Probability
Integer representing probability, weight, or chance used when selecting or placing variants (interpretation depends on the consumer). -
public int m_PrefabSubIndex
Index referencing a sub-prefab or variant inside a prefab (used when a prefab contains multiple sub-items).
Properties
- None (this is a plain data struct with public fields).
Note: Being an IComponentData struct it will have the default value-type constructor.
Constructors
public ObjectDefinition()
Default value-type constructor is used. No explicit constructors are defined. Initialize fields manually when creating instances.
Methods
- None defined on this type.
Note: The struct is intended as plain data for ECS; behavior is implemented by systems/jobs that read/write this component.
Usage Example
// Example: adding an ObjectDefinition to an entity
using Unity.Entities;
using Unity.Mathematics;
using Game.Tools;
public void CreateObject(EntityManager entityManager, Entity entity)
{
var def = new ObjectDefinition
{
m_Position = new float3(10f, 0f, 20f),
m_LocalPosition = new float3(0f, 0f, 0f),
m_Scale = new float3(1f, 1f, 1f),
m_Rotation = quaternion.EulerXYZ(new float3(0f, math.radians(45f), 0f)),
m_LocalRotation = quaternion.identity,
m_Elevation = 0.0f,
m_Intensity = 1.0f,
m_Age = 0f,
m_ParentMesh = -1, // no parent
m_GroupIndex = 0,
m_Probability = 100,
m_PrefabSubIndex = 0
};
entityManager.AddComponentData(entity, def);
}
Additional notes: - Treat this struct as POD data in jobs and systems. Keep field interpretations consistent with the consuming systems (placement, rendering, LOD, etc.). - Because it implements IQueryTypeParameter, it can be used directly in certain query expressions and APIs that accept query-type parameters.