Skip to content

Game.Effects.EffectInstance

Assembly:
Assembly-CSharp (or the assembly your mod compiles into)

Namespace: Game.Effects

Type: struct (value type)

Base: Implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary: Represents a simple ECS component that describes a single effect instance in the world by storing its position, rotation and intensity. Intended for use with Unity's DOTS/ECS (safe to use in jobs and queries). This struct is blittable and can be added to entities to mark them as effect instances or to pass effect data into systems/jobs.


Fields

  • public Unity.Mathematics.float3 m_Position World-space position of the effect instance. Use Unity.Mathematics.float3 (requires using Unity.Mathematics).

  • public Unity.Mathematics.quaternion m_Rotation Orientation of the effect instance as a quaternion. Use Unity.Mathematics.quaternion.

  • public System.Single m_Intensity Effect intensity or strength (single-precision float). Semantics are defined by the effect subsystem (e.g., scale, amplitude, visibility).

Properties

  • (none)

Constructors

  • public EffectInstance() No explicit constructors are defined in the source — the default parameterless struct constructor is used. Initialize fields inline or with an object initializer when creating instances.

Methods

  • (none)

Usage Example

using Unity.Entities;
using Unity.Mathematics;
using Game.Effects;

// Create and add to an entity via EntityManager
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity effectEntity = entityManager.CreateEntity();

// Initialize fields using an object initializer
var effect = new EffectInstance
{
    m_Position = new float3(10f, 0f, 5f),
    m_Rotation = quaternion.EulerXYZ(new float3(0f, math.radians(45f), 0f)),
    m_Intensity = 1.5f
};

entityManager.AddComponentData(effectEntity, effect);

// Example usage inside a SystemBase or Job:
// SystemBase:
Entities
    .ForEach((ref EffectInstance e) =>
    {
        // read/modify effect data, e.g. fade intensity
        e.m_Intensity = math.max(0f, e.m_Intensity - 0.01f);
    })
    .ScheduleParallel();

Notes: - Because this type implements IComponentData and is blittable, it is safe to access from jobs and scheduled systems. - The IQueryTypeParameter marker allows this type to be used conveniently in certain query APIs — treat it as a plain component for most ECS operations. - Remember to include using Unity.Mathematics; when working with float3 and quaternion.