Calimero
Hectopat
- Katılım
- 19 Aralık 2020
- Mesajlar
- 119
Daha fazla
- Cinsiyet
- Erkek
Unity de ımage nesnelerine kolayca gradient renkler uygulayan bir script yazıyorum ve şu an için üçlü gradient renk(firstcolor, middlecolor ve endcolor) seçeneği ekledim fakat middlecolor çok az belli oluyor. Mixpointler arasındaki mesafeyi arttırmam gerektiğini düşünüyorum fakat bir türlü yapamadım.
Kodum:
Kodum:
C#:
Texture2D GradientTextureTriple(Color startColor, Color middleColor, Color endColor, int textureWidth, float mixPosition)
{
Texture2D texture = new Texture2D(textureWidth, 1);
Color[] gradientColors = new Color[textureWidth];
for (int i = 0; i < textureWidth; i++)
{
float t = Mathf.InverseLerp(0, textureWidth - 1, i);
gradientColors[i] = Color.Lerp(
Color.Lerp(startColor, middleColor, t),
Color.Lerp(middleColor, endColor, t),
Mathf.Lerp(0, 1, Mathf.Clamp01(t - mixPosition)));
}
texture.SetPixels(gradientColors);
texture.Apply();
return texture;
}