CCGradient can be used to create color gradients. They consist of multiple color stops inside a [0,1]
range and are resolution independent. You either export them to PNG or access them directly in code.
You can create a new gradient asset inside Unity via Assets / Create / Gradient.
Preview
You can customize how the gradient is shown in the preview area.
You can use from and to to modify the shown range. This is useful to preview different wrap modes.
You can also switch between showing colors with transparency on a checkered background (RGBA), colors without alpha, and alpha
only.
Stops
A gradient consists of a number of stops (at least one). They define colors for specific positions inside a [0,1] range.
Input values that fall between two stops produce an interpolated color.
If the first stop is above 0, there's an implicit stop at 0 with the same color as the first stop.
Likewise for the last stop and 1.
It's possible for consecutive stops to have the same position. This results in a sharp color transition.
It's even possible for the next stop to have a lower position. If so, it will be at least partially hidden by its predecessor.
Interpolation
Interpolation controls how colors are interpolated between stops.
Linear
Use linear interpolation.
Smooth
Use a smooth interpolation that transitions slower when close to a stop.
Wrap
Wrap controls how positions outside the [0,1] range are colored.
Clamp
Repeat the colors at the extremes, like 000012222.
Repeat
Repeat the gradient each unit increment, like 012012012.
Flip
Repeat and reverse the gradient each unit increment, like 210012210.
Gradient Exporter
You can export gradients using the Gradient Exporter window. You can open it via
Window / Catlike Coding / Gradient Exporter or by clicking the Export PNG file button in a
gradient's inspector. If opened without a gradient selected, it will initially be rather empty.
Minimum and Maximum can be used to change the range that will be exported. This is useful for
repeating or flipping gradients.
Pixels controls how many pixels wide the exported PNG will be. More pixels results in a more precise
gradient map.
Bilinear Preview toggles whether the export preview shows a bilinearly interpolated image or the
actual pixels.
Press the Export PNG file button to save the gradient map to a PNG file and import it into Unity.
By default, the exporter places the file in the same directory as the source gradient, with " map" appended to the source gradient's name.