Game.Prefabs.VFX
Assembly: Game (inferred from file path)
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
VFX is a prefab component class used to declare a visual effect asset and a maximum instance count for prefab/ECS integration. It exposes a UnityEngine.VFX.VisualEffectAsset reference (m_Effect) and an integer limit (m_MaxCount). When used as a prefab definition, it registers the runtime component VFXData on the prefab's component list so the ECS/streaming code knows to include VFX-related runtime data for instances of this prefab. It is annotated with ComponentMenu to expose it under the "VFX/" menu in the editor and to associate it with EffectPrefab in tools/inspectors.
Fields
-
public UnityEngine.VFX.VisualEffectAsset m_Effect
Holds a reference to a VisualEffectAsset (VFX Graph asset) that will be used by the prefab. This asset defines the visual effect to spawn/play for this prefab at runtime. -
public int m_MaxCount
Optional integer limit describing the maximum number of simultaneous instances (or a configurable cap used by the spawning/pooling system). The concrete meaning depends on the game's runtime systems that consume this prefab data (e.g., pooling or throttling VFX instances for performance).
Properties
- (none)
Constructors
- (default parameterless constructor generated by compiler)
No explicit constructors are declared in the source — the default constructor is used.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds runtime component types that should be present on entities created from this prefab. Implementation adds ComponentType.ReadWrite() to the provided set, ensuring that spawned prefab entities include the VFXData component (used by runtime systems to manage the effect). -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Empty override. Intended to add components to an archetype when building an entity archetype from this prefab in some contexts; currently no archetype-only components are added here.
Usage Example
// Example: simple inspector- or prefab-setup usage
// Attach the VFX component to a prefab, assign a VisualEffectAsset and set a max count.
public class MyPrefabSetup
{
public void Configure(VFX vfxComponent, UnityEngine.VFX.VisualEffectAsset asset)
{
vfxComponent.m_Effect = asset;
vfxComponent.m_MaxCount = 10; // limit concurrent instances if runtime system respects this
}
}
Notes: - This component requires the UnityEngine.VFX package (VisualEffectAsset) and Unity.Entities types (ComponentType). - The runtime type VFXData referenced in GetPrefabComponents must exist in the game/mod; it is the runtime ECS component used to carry instance/state information for the VFX. If you implement systems that consume VFXData, ensure they read the prefab's m_Effect and m_MaxCount as needed. - The ComponentMenu attribute places this component under the "VFX/" category in the editor and associates it with EffectPrefab for tooling convenience.