浏览代码

Merge pull request #144 from Unity-Technologies/color_config_hex_values

Hex color representation in semantic segmentation label config UI
/main
GitHub 4 年前
当前提交
103cd522
共有 2 个文件被更改,包括 9 次插入2 次删除
  1. 6
      com.unity.perception/Editor/GroundTruth/SemanticSegmentationLabelConfigEditor.cs
  2. 5
      com.unity.perception/Editor/GroundTruth/Uxml/ColoredLabelElementInLabelConfig.uxml

6
com.unity.perception/Editor/GroundTruth/SemanticSegmentationLabelConfigEditor.cs


.FindPropertyRelative(nameof(SemanticSegmentationLabelEntry.label)));
addedLabel.colorField.BindProperty(m_SerializedLabelsArray.GetArrayElementAtIndex(i)
.FindPropertyRelative(nameof(SemanticSegmentationLabelEntry.color)));
addedLabel.hexLabel.text = "#"+ColorUtility.ToHtmlStringRGBA(m_SerializedLabelsArray.GetArrayElementAtIndex(i)
.FindPropertyRelative(nameof(SemanticSegmentationLabelEntry.color)).colorValue);
}
}

protected override string UxmlPath => k_UxmlDir + "ColoredLabelElementInLabelConfig.uxml";
public ColorField colorField;
public Label hexLabel;
public ColoredLabelElementInLabelConfig(LabelConfigEditor<SemanticSegmentationLabelEntry> editor, SerializedProperty labelsArray) : base(editor, labelsArray)
{ }

colorField = this.Q<ColorField>("label-color-value");
hexLabel = this.Q<Label>("label-color-hex");
colorField.RegisterValueChangedCallback((cEvent) =>
{

Debug.LogWarning("A label with the chosen color " + cEvent.newValue + " has already been added to this label configuration.");
}
hexLabel.text = "#"+ColorUtility.ToHtmlStringRGBA(colorField.value);
});
}

5
com.unity.perception/Editor/GroundTruth/Uxml/ColoredLabelElementInLabelConfig.uxml


<VisualElement class="added-label" style="padding-top: 3px;">
<Button name="remove-button" class="labeling__remove-item-button"/>
<VisualElement class="generic-hover"
style="flex-direction: row; padding: 3px 0 3px 6px; margin-left: 3px; margin-right: 3px; border-width: 1px; border-color: #555555; border-radius: 4px;">
<editor:ColorField name="label-color-value" style="min-width : 60px; max-width: 60px; align-self:center;"/>
style="min-width : 137px; flex-direction: row; padding: 3px 0 3px 6px; margin-left: 3px; margin-right: 3px; border-width: 1px; border-color: #555555; border-radius: 4px;">
<editor:ColorField name="label-color-value" style="min-width : 60px; max-width: 60px; align-self:center; margin:2px"/>
<Label name="label-color-hex" style="font-size: 11; min-width : 60px; max-width: 60px; align-self:center;"/>
</VisualElement>
<TextField name="label-value" class="labeling__added-label-value"/>
<VisualElement style="min-width:20px; flex-direction: row; display:none">

正在加载...
取消
保存