public ColorRGBSlotControlView(ColorRGBMaterialSlot slot) { m_Slot = slot; var colorField = new ColorField { value = new Color(slot.value.x, slot.value.y, slot.value.z, 0), showAlpha = false }; colorField.OnValueChanged(OnValueChanged); Add(colorField); }
public static void RenderColorProperty(VisualElement container, string name, object value, Action <object> setter) { var field = new ColorField(name); field.SetValueWithoutNotify((Color)value); field.MarkDirtyRepaint(); field.RegisterValueChangedCallback(evt => setter(evt.newValue)); container.Add(field); }
public ColorRGBASlotControlView(ColorRGBAMaterialSlot slot) { m_Slot = slot; var colorField = new ColorField { value = slot.value, showEyeDropper = false }; colorField.OnValueChanged(OnValueChanged); Add(colorField); }
private void DrawPalette() { var palette = m_Root.Q <VisualElement>(name: "palette"); palette.Clear(); var paletteSO = new SerializedObject(pixelAsset.Palette); var picker = new ObjectField(); picker.objectType = typeof(Palette); picker.BindProperty(paletteSO); // palette.Add(new IMGUIContainer(PaletteDrawOnGUI)); palette.style.backgroundColor = Color.black; var colorsProp = paletteSO.FindProperty("Colors"); for (int i = 0; i < colorsProp.arraySize; i++) { if (i == paletteIndex) { var entry = new ColorField(); entry.pickingMode = PickingMode.Position; entry.BindProperty(colorsProp.GetArrayElementAtIndex(i)); entry.showEyeDropper = false; entry.showAlpha = false; entry.style.width = entry.style.height = 18; entry.style.marginLeft = entry.style.marginRight = 0; entry.style.marginTop = entry.style.marginBottom = 0; entry.style.borderColor = Color.white; entry.style.borderLeftWidth = entry.style.borderRightWidth = 1; entry.style.borderTopWidth = entry.style.borderBottomWidth = 1; entry.style.borderBottomLeftRadius = entry.style.borderBottomRightRadius = 2; entry.style.borderTopLeftRadius = entry.style.borderTopRightRadius = 2; entry.RegisterValueChangedCallback(OnPaletteEdit); palette.Add(entry); } else { var index = i; var entry = new Button(() => { paletteIndex = index; var colors = palette.Query <VisualElement>(); colors.ForEach(c => palette.Remove(c)); DrawPalette(); }); entry.style.backgroundImage = EditorGUIUtility.whiteTexture; entry.style.unityBackgroundImageTintColor = (Color)pixelAsset.Palette.Colors[i]; entry.style.width = entry.style.height = 16; entry.style.marginLeft = entry.style.marginRight = 1; entry.style.marginTop = entry.style.marginBottom = 1; palette.Add(entry); } } DrawFrames(); // palette.style.height = (pixelAsset.Palette.Colors.Length / 4) * 18; }
public ColorRGBASlotControlView(ColorRGBAMaterialSlot slot) { styleSheets.Add(Resources.Load <StyleSheet>("Styles/Controls/ColorRGBASlotControlView")); m_Slot = slot; var colorField = new ColorField { value = slot.value, showEyeDropper = false }; colorField.RegisterValueChangedCallback(OnValueChanged); Add(colorField); }
private void ConfigColors() { foreach (KeyValuePair <string, Color> pair in colorTheme.GetSection("General")) { ColorField c = new ColorField(OptionNameToLabelName(pair.Key), pair.Value); colors.Add(c); colorTab.Controls.Add(c); } DoColorLayout(); }
public ColorRGBASlotControlView(ColorRGBAMaterialSlot slot) { AddStyleSheetPath("Styles/Controls/ColorRGBASlotControlView"); m_Slot = slot; var colorField = new ColorField { value = slot.value, showEyeDropper = false }; colorField.OnValueChanged(OnValueChanged); Add(colorField); }
public ColorRGBSlotControlView(ColorRGBMaterialSlot slot) { AddStyleSheetPath("Styles/Controls/ColorRGBSlotControlView"); m_Slot = slot; var colorField = new ColorField { value = new Color(slot.value.x, slot.value.y, slot.value.z, 0), showEyeDropper = false, showAlpha = false, hdr = (slot.colorMode == ColorMode.HDR) }; colorField.OnValueChanged(OnValueChanged); Add(colorField); }
public ColorRGBSlotControlView(ColorRGBMaterialSlot slot) { styleSheets.Add(Resources.Load <StyleSheet>("Styles/Controls/ColorRGBSlotControlView")); m_Slot = slot; var colorField = new ColorField { value = new Color(slot.value.x, slot.value.y, slot.value.z, 0), showEyeDropper = false, showAlpha = false, hdr = (slot.colorMode == ColorMode.HDR) }; colorField.RegisterValueChangedCallback(OnValueChanged); Add(colorField); }
void Init() { ColorField field = new ColorField() { value = config.value != null ? (Color)config.value : new Color(), }; field.RegisterValueChangedCallback((e) => { config.OnValueChanged(e.newValue); MarkDirtyRepaint(); }); Add(field); }
public FoldoutColorField() { m_ColorField = new ColorField(); m_ColorField.name = "field"; m_ColorField.AddToClassList(k_FieldClassName); m_ColorField.RegisterValueChangedCallback((e) => m_MixedValueLine.style.display = DisplayStyle.None); header.hierarchy.Add(m_ColorField); m_MixedValueLine = new VisualElement(); m_MixedValueLine.name = "mixed-value-line"; m_MixedValueLine.AddToClassList(k_MixedValueLineClassName); m_ColorField.Q <IMGUIContainer>().hierarchy.Add(m_MixedValueLine); }
public static void DrawControl(this FieldControl <Color> control) { ColorField input = control.AddColorField(control.value); control.eventManager.AddListener <ListItemInputChange>(e => { if (e.input != input) { return; } control.value = input.value; control.eventManager.Raise <FieldControlUpdated <Color> >(new FieldControlUpdated <Color>(control)); }); }
public ColorField AddColorField(Color value = new Color(), bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false) { ColorField el = new ColorField(); el.value = value; el.AddToClassList("list-item-input"); el.AddToClassList("list-item-color-input"); AddAlternates(el, alternate, secondAlternate, thirdAlternate); el.RegisterValueChangedCallback(e => { eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el)); }); this.Add(el); return(el); }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { if (property.propertyType == SerializedPropertyType.Color) { var colorUsage = (ColorUsageAttribute)attribute; var field = new ColorField(property.displayName); field.showAlpha = colorUsage.showAlpha; field.hdr = colorUsage.hdr; field.bindingPath = property.propertyPath; return(field); } return(new Label(s_InvalidTypeMessage)); }
private void OnModelPropertyChanged(object sender, PropertyChangedEventArgs e) { if (HeaderField != null && HeaderField.Contains(e.PropertyName)) { BeginInvokeInUiThread(SyncHeaderAutomatic); } if (StatusField != null && StatusField.Contains(e.PropertyName)) { BeginInvokeInUiThread(SyncStatusImageAutomatic); } if (ColorField != null && ColorField.Contains(e.PropertyName)) { BeginInvokeInUiThread(SyncColorAutomatic); } }
public Color GetColor(ColorField color) { switch (color) { case ColorField.Bg_FloatingUIObject_Highlightet: return(bg_FloatingUIObject_Highlightet); case ColorField.Bg_FloatingUIObject: return(bg_FloatingUIObject); case ColorField.Txt_FloatingUIObject_Highlightet: return(txt_FloatingUIObject_Highlightet); case ColorField.Txt_FloatingUIObject: return(txt_FloatingUIObject); default: return(Color.white); } }
protected override void OnEnable() { base.OnEnable(); equipmentDef = TargetType.eliteEquipmentDef; prefix = Settings.GetPrefix1stUpperRestLower() + "Affix"; prefixUsesTokenPrefix = true; OnVisualTreeCopy += () => { header = Find <VisualElement>("Header"); inspectorData = Find <VisualElement>("InspectorData"); color = Find <ColorField>(inspectorData, "color"); messages = Find <VisualElement>("Messages"); }; }
private void OnEnable() { TextField message = new TextField("Сообщение"); ColorField color = new ColorField("Выбор цвета"); Button send = new Button(() => { Debug.Log(message); }); send.text = "Отправить!"; rootVisualElement.Add(message); rootVisualElement.Add(color); rootVisualElement.Add(send); }
protected override void DrawInspectorGUI() { var label = Find <Label>(header, "m_Name"); label.RegisterValueChangedCallback((cb) => EnsureNamingConventions(cb)); Find <Button>(inspectorData, "tokenSetter").clicked += SetTokens; color = Find <ColorField>(inspectorData, "color"); Find <Button>(color, "colorSetter").clicked += SetColor; var equipDef = Find <PropertyField>(inspectorData, "eliteEquipmentDef"); equipDef.RegisterCallback <ChangeEvent <EquipmentDef> >(CheckEquipDef); CheckEquipDef(); }
public override void OnActivate(string searchContext, VisualElement root) { var padRect = new VisualElement(); int padding = 10; padRect.style.paddingBottom = padding; padRect.style.paddingLeft = padding; padRect.style.paddingRight = padding; padRect.style.paddingTop = padding - 5; root.Add(padRect); var title = new Label("Notch Solution"); title.style.fontSize = 15; title.style.unityFontStyleAndWeight = FontStyle.Bold; padRect.Add(title); var repo = new Label("https://github.com/5argon/NotchSolution"); repo.style.paddingBottom = 15; repo.style.unityFontStyleAndWeight = FontStyle.Bold; repo.RegisterCallback((MouseDownEvent ev) => { System.Diagnostics.Process.Start("https://github.com/5argon/NotchSolution"); }); padRect.Add(repo); var devicesPath = new TextField("Device Directory"); devicesPath.SetEnabled(false); devicesPath.value = NotchSimulatorUtility.DevicesFolder; padRect.Add(devicesPath); var colorField = new ColorField("Prefab mode overlay color"); colorField.value = Settings.Instance.PrefabModeOverlayColor; colorField.RegisterValueChangedCallback(ev => { var settings = Settings.Instance; settings.PrefabModeOverlayColor = ev.newValue; settings.Save(); NotchSimulator.UpdateAllMockups(); NotchSimulator.UpdateSimulatorTargets(); }); padRect.Add(colorField); }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { var name = GetNameProperty(property); var settings = GetSettingsProperty(property); var val = GetValProperty(property); var mode = (ColorParameter.ColorMode)settings.FindPropertyRelative(nameof(ColorParameter.ColorSettings.mode)).intValue; var colorField = new ColorField(name.stringValue) { value = val.colorValue, hdr = mode == ColorParameter.ColorMode.HDR }; colorField.RegisterValueChangedCallback(e => { val.colorValue = e.newValue; ApplyModifiedProperties(property); }); return(colorField); }
protected override void InitExtended() { colorField = this.Q <ColorField>("label-color-value"); colorField.RegisterValueChangedCallback((cEvent) => { var index = ((SemanticSegmentationLabelConfigEditor)m_LabelConfigEditor).IndexOfGivenColorInSerializedLabelsArray(cEvent.newValue); if (index != -1 && index != indexInList) { //The listview recycles child visual elements and that causes the RegisterValueChangedCallback event to be called when scrolling. //Therefore, we need to make sure we are not in this code block just because of scrolling, but because the user is actively changing one of the labels. //The index check is for this purpose. Debug.LogWarning("A label with the chosen color " + cEvent.newValue + " has already been added to this label configuration."); } }); }
public override void Enable() { base.Enable(); colorNode = nodeTarget as ColorNode; var colorField = new ColorField() { label = "Color", value = colorNode.color }; colorField.RegisterValueChangedCallback(e => { owner.RegisterCompleteObjectUndo("Updated Color " + e.newValue); NotifyNodeChanged(); colorNode.color = e.newValue; }); controlsContainer.Add(colorField); }
public override VisualElement CreateElement(Type type, object initial) { var colorField = new ColorField(); if (initial.GetType() == typeof(Color)) { colorField.value = (Color)initial; } else if (initial.GetType() == typeof(Color32)) { colorField.value = (Color32)initial; colorField.RegisterValueChangedCallback(evt => { using ChangeEvent <Color32> evt2 = ChangeEvent <Color32> .GetPooled(evt.previousValue, evt.newValue); evt.currentTarget.SendEvent(evt2); }); } return(colorField); }
public override void LoadContent() { continueTex = Content.Load <Texture2D>("Textures/Menu/Continue"); howToPlayTex = Content.Load <Texture2D>("Textures/Menu/HowToPlay"); exitTex = Content.Load <Texture2D>("Textures/Menu/Exit"); float yOffset = 10f; /* * buttonContinue = new Button(continueTex, new Vector2(Game1.screenSize.X / 2, 250), Resources.ColorHighLight, 9, 0); * buttonHowToPlay = new Button(howToPlayTex, new Vector2(buttonContinue.getPosX(), buttonContinue.getPosY() + yOffset + howToPlayTex.Height), Resources.ColorHighLight, 1, 0); * buttonExit = new Button(exitTex, new Vector2(buttonHowToPlay.getPosX(), buttonHowToPlay.getPosY() + yOffset + exitTex.Height), Resources.ColorHighLight, 0, 4); */ buttonContinue = new Button(continueTex, new Vector2(Game1.screenSize.X / 2, 250), Resources.ColorHighLight, Button.ButtonType.ChangeLevelPop, 0); buttonHowToPlay = new Button(howToPlayTex, new Vector2(buttonContinue.getPosX(), buttonContinue.getPosY() + yOffset + howToPlayTex.Height), Resources.ColorHighLight, Button.ButtonType.ChangeLevelPush, 8); buttonExit = new Button(exitTex, new Vector2(buttonHowToPlay.getPosX(), buttonHowToPlay.getPosY() + yOffset + exitTex.Height), Resources.ColorHighLight, Button.ButtonType.ChangeLevelSet, 4); pauseTransparency = new ColorField(Resources.ColorPause, new Rectangle(0, 0, (int)Game1.screenSize.X, (int)Game1.screenSize.Y)); }
public static INotifyValueChanged <T> GetField <T>(string label, T value, out VisualElement field) { var type = typeof(T); field = null; if (type == typeof(string)) { field = new TextField(label); } else if (type == typeof(int)) { field = new IntegerField(label); } else if (type == typeof(bool)) { field = new Toggle(label); } else if (type == typeof(Enum)) { field = new EnumField(label, Convert <Enum>(value)); } else if (type == typeof(Color)) { field = new ColorField(label); ((ColorField)field).showAlpha = true; } else if (type == typeof(float)) { field = new FloatField(label); } else { throw new NotImplementedException(); } var result = (INotifyValueChanged <T>)field; result.value = value; return(result); }
private void OnEnable() { var root = rootVisualElement; var UXML = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/CreateFieldBackgroundWindow.uxml"); UXML.CloneTree(root); var button = root.Query <Button>("CreateButton").First(); _mainGameSettingsField = root.Query <ObjectField>("MainGameSettings").First(); _xOffsetField = root.Query <FloatField>("X_OffsetField").First(); _yOffsetField = root.Query <FloatField>("Y_OffsetField").First(); _spawnPointField = root.Query <ObjectField>("StartPointField").First(); _parentField = root.Query <ObjectField>("ParentField").First(); _cellColorField = root.Query <ColorField>("CellColorField").First(); _backgroundColorField = root.Query <ColorField>("BackgroundColorField").First(); _cellPrefabField = root.Query <ObjectField>("SpritePrefabField").First(); _backgroundPrefabField = root.Query <ObjectField>("BackgroundPrefabField").First(); button.clicked += CreateBackground; }
public ColorControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo) { m_Node = node; m_PropertyInfo = propertyInfo; if (propertyInfo.PropertyType != typeof(Color)) { throw new ArgumentException("Property must be of type Color.", "propertyInfo"); } label = label ?? ObjectNames.NicifyVariableName(propertyInfo.Name); if (!string.IsNullOrEmpty(label)) { Add(new Label(label)); } var colorField = new ColorField { value = (Color)m_PropertyInfo.GetValue(m_Node, null) }; colorField.OnValueChanged(OnChange); Add(colorField); }
// Methods ////////////////////////////////////////////////////////////////////// public override void SetData(object data) { if (data == null) { _text = null; } else { _text = data.GetType() == typeof(System.Drawing.Color) ? ColorField.ColorToString((System.Drawing.Color)data) : data.ToString(); } _shortTextBox.Text = Convert.ToString(_text); #region template if ((!UseBrowseTemplate && !UseEditTemplate) && !UseInlineEditTemplate) { return; } // synchronize data with controls are given in the template var title = GetLabelForTitleControl() as Label; var desc = GetLabelForDescription() as Label; var innerControl = GetInnerControl() as TextBox; if (title != null) { title.Text = this.Field.DisplayName; } if (desc != null) { desc.Text = this.Field.Description; } if (innerControl != null) { innerControl.Text = Convert.ToString(_text); } #endregion }
internal VisualElement CreateGUI( ValueChangedCallback valueChangedCallback, Color fieldToDraw, string labelName, out VisualElement propertyColorField, int indentLevel = 0) { var colorField = new ColorField { value = fieldToDraw, showEyeDropper = false, hdr = false }; if (valueChangedCallback != null) { colorField.RegisterValueChangedCallback(evt => { valueChangedCallback((Color)evt.newValue); }); } propertyColorField = colorField; var defaultRow = new PropertyRow(PropertyDrawerUtils.CreateLabel(labelName, indentLevel)); defaultRow.Add(propertyColorField); return(defaultRow); }