Parameter vs. Attribute in Unity's VFX Graph⚓︎
In Unity's VFX Graph, "Parameters" and "Attributes" are two common concepts used to control and adjust particle effects, but they serve different purposes and are used in distinct ways. Here's an explanation of the difference between them
Parameters⚓︎
Parameters
Parameters are variables used to control and adjust the effect from outside of the VFX Graph. Parameters can be exposed in the Inspector
, allowing you to adjust them directly in the editor or dynamically change their values during runtime through scripts.
- Definition: Defined on the VFX Graph's Blackboard.
- Purpose: To control the VFX Graph from external sources. E.g. particle color, particle speed, emission rate, or dynamically changes the VFX effect during runtime through a script, etc.
Attributes⚓︎
Attributes
Attributes are used to control the properties of individual particles within the particle system. Each particle has its own attributes, which determine its behavior and appearance. Common particle attributes include position, velocity, color, size, etc. User can add "Custom attributes" to create more complex and customized effects.
- Definition: Attributes are defined and used inside the VFX Graph, typically set and read during the Initialize, Update, and Output stages of a particle.
- Purpose: To control the properties and behavior of each particle in the system. E.g. particle's lifespan, initial position, initial velocity, or color over time, etc.
Summary of Differences⚓︎
- Scope:
- Parameters: Control the entire VFX Graph externally and can be adjusted in the editor or dynamically via scripts.
- Attributes: Control the properties and behavior of individual particles within the VFX Graph.
- Definition and Use:
- Parameters: Defined on the Blackboard and typically exposed for external use.
- Attributes: Defined and used inside the VFX Graph to control specific particle behavior and appearance.
- Purpose:
- Parameters: Used for external interaction and dynamic adjustment of the VFX effect.
- Attributes: Used internally within the particle system to control individual particles.