private UIColorField CreateColorField(UIComponent parent) { if (colorFIeldTemplate == null) { UIComponent template = UITemplateManager.Get("LineTemplate"); if (template == null) { return(null); } colorFIeldTemplate = template.Find <UIColorField>("LineColor"); if (colorFIeldTemplate == null) { return(null); } } UIColorField cF = Instantiate(colorFIeldTemplate.gameObject).GetComponent <UIColorField>(); parent.AttachUIComponent(cF.gameObject); cF.name = "PainterColorField"; cF.AlignTo(parent, UIAlignAnchor.TopRight); cF.relativePosition += new Vector3(-40f, 43f, 0f); cF.size = new Vector2(26f, 26f); cF.pickerPosition = UIColorField.ColorPickerPosition.RightBelow; cF.eventSelectedColorChanged += EventSelectedColorChangedHandler; cF.eventColorPickerOpen += EventColorPickerOpenHandler; return(cF); }
public static UIColorField CreateColorField(this UIComponent parent, string text, Vector2 position) { UIComponent template = UITemplateManager.Get("LineTemplate"); if (template == null) { return(null); } UIColorField colorFIeldTemplate = template.Find <UIColorField>("LineColor"); if (colorFIeldTemplate == null) { return(null); } UIColorField colorField = Object.Instantiate(colorFIeldTemplate.gameObject).GetComponent <UIColorField>(); parent.AttachUIComponent(colorField.gameObject); colorField.name = "PainterColorField"; colorField.AlignTo(parent, UIAlignAnchor.TopRight); colorField.position = position; colorField.size = new Vector2(40f, 40f); colorField.pickerPosition = UIColorField.ColorPickerPosition.RightBelow; return(colorField); }