Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
using UnityEngine.UI;
// For a discussion of the code, see: https://www.hallgrimgames.com/blog/2018/11/25/custom-unity-ui-meshes
public class MyUiElement : MaskableGraphic
{
public float GridCellSize = 40f;
[SerializeField]
@halgrimmur
halgrimmur / MixColors.cs
Created August 13, 2018 18:18
Mixing Colors in Unity, Water-Color style, by (negative) Averaging!
// Calculates the average of all colors in the list.
// Normal averaging would yield additive color mixing,
// ... i.e. the way *light* of color would mix.
// Colored liquids, like water colors, mix in a
// subtractive way, though, i.e. red+blue = purple.
// See https://en.wikipedia.org/wiki/Color_mixing
Color GetSubtractiveAverageColor(List<Color> colors)
{
var invertedColorSum = Color.black;