private void UpdateColorList(List <Color32> colors) { UIPanel[] colorPickers = m_colorFieldTemplateListColors.SetItemCount(colors.Count); for (int i = 0; i < colors.Count; i++) { UIColorField colorField = colorPickers[i].GetComponentInChildren <UIColorField>(); if (canEdit && colorField.objectUserData == null) { colorField.colorPicker = KlyteMonoUtils.GetDefaultPicker(); colorField.eventSelectedColorReleased += (x, y) => { if (GetPaletteName(out string paletteName)) { var palette = TLMAutoColorPaletteContainer.GetPalette(paletteName); var selColor = ((UIColorField)x).selectedColor; palette[x.parent.zOrder] = selColor; if (selColor == default) { ((UIColorField)x).isVisible = false; ((UIColorField)x).OnDisable(); } StartCoroutine(SavePalette(paletteName)); } }; colorField.eventColorPickerOpen += KlyteMonoUtils.DefaultColorPickerHandler; colorField.objectUserData = true; } (colorField.triggerButton as UILabel).text = $"{i.ToString("0")}"; (colorField.triggerButton as UILabel).textColor = KlyteMonoUtils.ContrastColor(colors[i]); (colorField.triggerButton as UILabel).disabledTextColor = KlyteMonoUtils.ContrastColor(colors[i]); colorField.selectedColor = colors[i]; colorField.isVisible = true; } if (canEdit) { m_addColor.zOrder = 99999999; } }