This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |