format
typescript
PSGradient.Evaluate(time, random_value)class: PSGradient
description
Performs color sampling.
The purpose of this method is to retrieve the color value of a gradient at a specific time point, allowing you to dynamically obtain color values throughout the lifecycle of a particle system.
parameter
| param_name | type | description |
|---|---|---|
| time | number | The sampling time point. |
| random_value | number | A random value. |
reture
| type | description |
|---|---|
Color | The sampled color. |
code example
typescript
class New_TypeScript
extends Component{
// Declare a PSGradient
private psGradient: PSGradient;
OnStart(): void {
let obj = new GameObject();
let com = obj.AddComponent<ParticleSystem>(ParticleSystem);
// Initialize the PSGradient
this.psGradient = com.initialModuleColor;
}
OnUpdate(): void {
let time = 1;
let color = this.psGradient.Evaluate(time);
Debug.Log("The color of the gradient at", time, "seconds is:", value);
}
}