skip to Main Content

Scripting Support (C#)

The asset provides scripting support so you can use your palettes and apply them in runtime from code.
Particularly, the CSPalette class can be instantiated as follows:

// Create a palette which uses a split complementary design based on red color as
CSPalette palette = ScriptableObject.CreateInstance<CSPalette>();
palette.ConfigurePalette(ColorScheme.SplitComplementary,, splitAmount: 0.6f);

// Build chromatic colors

// Output the palette hue colors
for (int k=0;k<palette.colorsCount;k++) {

// Build palette colors (including shades)
for (int k=0;k<paletteColors.Length;k++) {

Other useful methods provided by the CSPalette class:

// Builds a LUT based on the current color palette
Texture2D ExportLUT() 

// Builds a texture containing the color palette
Texture2D ExportTexture()

// Transforms a color based on a given LUT
Color ApplyLUT(Color, LUT) 

// Returns the nearest color of the palette
Color GetNearestColor(Color, ColorMatchMode) 

// Returns the nearest colors of the palette
Color[] GetNearestColors(Color[] originalColors) 

// Returns the nearest colors of the texture colors based on the palette
Color[] GetNearestColors(Texture, ColorMatchMode, ...) 

// Transforms the given texture based on the current palette
Texture2D GetNearestTexture(Texture, ColorMatchMode, ...)
Back To Top