private void CreateTemplateColorItem() { if (UITemplateUtils.GetTemplateDict().ContainsKey(COLOR_SELECTOR_TEMPLATE)) { UITemplateUtils.GetTemplateDict().Remove(COLOR_SELECTOR_TEMPLATE); } var go = new GameObject(); UIPanel panel = go.AddComponent <UIPanel>(); panel.size = new Vector2(36, 36); panel.autoLayout = true; panel.wrapLayout = false; panel.padding = new RectOffset(4, 4, 4, 4); panel.autoLayoutDirection = LayoutDirection.Horizontal; canEdit = KlyteMonoUtils.EnsureColorFieldTemplate(); KlyteMonoUtils.CreateUIElement(out UIColorField colorField, panel.transform); KlyteMonoUtils.InitColorField(colorField, 36); var triggerButton = UIHelperExtension.AddLabel(colorField, "0", 36); triggerButton.autoSize = false; triggerButton.size = colorField.size; triggerButton.backgroundSprite = "ColorPickerOutline"; triggerButton.outlineColor = Color.black; triggerButton.outlineSize = 1; triggerButton.textScale = 1; triggerButton.textAlignment = UIHorizontalAlignment.Center; triggerButton.verticalAlignment = UIVerticalAlignment.Middle; colorField.triggerButton = triggerButton; triggerButton.size = colorField.size; triggerButton.relativePosition = default; colorField.normalFgSprite = "ColorPickerColor"; colorField.pickerPosition = UIColorField.ColorPickerPosition.LeftBelow; if (!canEdit) { triggerButton.Disable(); } UITemplateUtils.GetTemplateDict()[COLOR_SELECTOR_TEMPLATE] = panel; }