private void OnPickerValueChanged(UIComponent comp, Color fieldValue) { if (comp == null) { return; } UITextField hexField = сolor0HexField; if (comp.name == "Color0Picker") { hexField = сolor0HexField; } else if (comp.name == "Color1Picker") { hexField = сolor1HexField; } else if (comp.name == "Color2Picker") { hexField = сolor2HexField; } else if (comp.name == "Color3Picker") { hexField = сolor3HexField; } hexField.text = ColorTypeConverter.ToRGBHex(fieldValue); }
private void SetupColorField(UIPanel colorPanel, UIColorField сolorPicker, UITextField colorHexField, uint colorIndex) { var colorLabel = colorPanel.Find <UILabel>("Name"); colorLabel.width = 180; сolorPicker.position = new Vector3(200.0f, 0.0f); сolorPicker.name = "Color" + colorIndex + "Picker"; colorHexField.name = "Color" + colorIndex + "Hex"; colorHexField.builtinKeyNavigation = true; colorHexField.normalBgSprite = "TextFieldPanel"; colorHexField.selectionSprite = "EmptySprite"; colorHexField.textColor = new Color32(12, 21, 22, 255); colorHexField.horizontalAlignment = UIHorizontalAlignment.Center; colorHexField.width = 90; colorHexField.height = 20; colorHexField.position = new Vector3(255.0f, -2.0f); var colorValue = ColorTypeConverter.ToRGBHex(сolorPicker.selectedColor); colorHexField.text = colorValue; }