Aetheria/Assets/Plugins/Celestial Body/Scripts/Script Utilities/TextureHelper.cs
Reinier Vens 53a91351b7 Procedural Planets
Integrated Sebastian Lague's Planet Generator
Created Tour function in SectorRenderer which makes the camera follow each terrestrial planet in turn
2020-12-05 23:43:02 +00:00

22 lines
No EOL
627 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class TextureHelper {
public static void TextureFromGradient (Gradient gradient, int width, ref Texture2D texture) {
if (texture == null || texture.width != width || texture.height != 1) {
texture = new Texture2D (width, 1);
texture.filterMode = FilterMode.Bilinear;
texture.wrapMode = TextureWrapMode.Clamp;
}
Color[] colours = new Color[width];
for (int i = 0; i < width; i++) {
float t = i / (width - 1f);
colours[i] = gradient.Evaluate (t);
}
texture.SetPixels (colours);
texture.Apply ();
}
}