Hi there,
Does any individual is aware of why a GradientColor property works effective within the editor however crash at runtime with this error : “TypeError: GradientRange isn’t a constructor”
@property
public outlineColor : GradientRange = new GradientRange();
I do know this class is initially utilized in 3d particles, however I need to use it in a customized element.
The Particle System was disabled within the characteristic cropping of the challenge settings.
I now not get errors, however at any time when the editor recompile the challenge, the adjustments made to the gradient within the editor are misplaced.
It reverts again to plain white gradient.
Which model are you utilizing
3.5.0
The reset of the gradient occurred as a result of i used to be modifying it from a prefab occasion.
When edited from the prefab itself or if the occasion is unlinked from the prefab, the gradient stays persistent.
In case somebody come throughout this and asks himself the best way to make use of the gradient property in a shader, I’ll end this publish by clarify it.
In your element, extract gradient evaluations in an array of colours. The results of the consider methodology must be cloned as a result of it reuses its return reference. You’ll have an array filled with the identical colour in any other case.
Set the property of your materials with this array.
@property(Gradient)
public outlineColor : Gradient = new Gradient();
const gradientData = new Array<Shade>(100);
for(let i = 0; i < 100; i++) {
gradientData[i] = this.outlineColor.consider(i / 100).clone();
}
this.customMaterial.setProperty('outlineColor', gradientData);
In your fragment shader, outline a vec4 array uniform and use its values in response to the uvs.
uniform Fixed {
vec4 outlineColor[100];
};
for(int i = 0; i < 100; i++) {
if(i == int(uv0.y * 100.0)) {
define.rgb = outlineColor[i].rgb;
break;
}
}
We’ll repair this bug in 3.6.0 launch model.Thanks