Here are the examples of the csharp api UnityEngine.Gradient.SetKeys(UnityEngine.GradientColorKey[], UnityEngine.GradientAlphaKey[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
19
View Source File : connectLine.cs
License : MIT License
Project Creator : alchemz
License : MIT License
Project Creator : alchemz
void Start()
{
LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>();
// lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
lineRenderer.widthMultiplier = 0.2f;
lineRenderer.numPositions = lengthOfLineRenderer;
// A simple 2 color gradient with a fixed alpha of 1.0f.
float alpha = 1.0f;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] { new GradientColorKey(c1, 0.0f), new GradientColorKey(c2, 1.0f) },
new GradientAlphaKey[] { new GradientAlphaKey(alpha, 0.0f), new GradientAlphaKey(alpha, 1.0f) }
);
lineRenderer.colorGradient = gradient;
}
19
View Source File : NodeGraphEditor.cs
License : MIT License
Project Creator : Interactml
License : MIT License
Project Creator : Interactml
public virtual Gradient GetNoodleGradient(XNode.NodePort output, XNode.NodePort input) {
Gradient grad = new Gradient();
// If dragging the noodle, draw solid, slightly transparent
if (input == null) {
Color a = GetTypeColor(output.ValueType);
grad.SetKeys(
new GradientColorKey[] { new GradientColorKey(a, 0f) },
new GradientAlphaKey[] { new GradientAlphaKey(0.6f, 0f) }
);
}
// If normal, draw gradient fading from one input color to the other
else {
Color a = GetTypeColor(output.ValueType);
Color b = GetTypeColor(input.ValueType);
// If any port is hovered, tint white
if (window.hoveredPort == output || window.hoveredPort == input) {
a = Color.Lerp(a, Color.white, 0.8f);
b = Color.Lerp(b, Color.white, 0.8f);
}
grad.SetKeys(
new GradientColorKey[] { new GradientColorKey(a, 0f), new GradientColorKey(b, 1f) },
new GradientAlphaKey[] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 1f) }
);
}
return grad;
}