Skip to content

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_nametypedescription
timenumberThe sampling time point.
random_valuenumberA random value.

reture

typedescription
ColorThe 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);
        
    }

}