How to set Particle2D Color to a saved gradient resource?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jarlowrey
$Particles2D.material.color = load(str("res://src/UI/Color/Red.tres"))

Throws an error because Red.tres is a Gradient. Is it possible to this property to a gradient from scripting?

It looks like its something like $Particles2D.material.trail_color_modifier.gradient = load(str("res://src/UI/Color/Red.tres")), but I’m getting a material is null error…

jarlowrey | 2018-02-17 16:29

This does not throw any errors, but the color is not changing

	var grad =
	grad.gradient = load(str("res://src/UI/Color/Red.tres"))
	$Particles2D.process_material.trail_color_modifier = grad

jarlowrey | 2018-02-17 16:34

:bust_in_silhouette: Reply From: jarlowrey
var grad =
grad.gradient = load(str("res://src/UI/Color/Red.tres"))
$Particles2D.process_material.color_ramp = grad

Or you can instead set the Particle’s Color Ramp to an empty/new Gradient Texture in the editor and use this simpler code

$Particles2D.process_material.color_ramp.gradient = load(str("res://src/UI/Color/Red.tres"))

Is it possible to open the Gradient Color Ramp window, the same way as $ColorPickerButton window ?

Pastuh | 2018-03-07 12:24

Particle2D → ParticleMaterial → Color → Color Ramp → Gradient

jarlowrey | 2018-03-12 22:15