浏览代码

Merge pull request #209 from Unity-Technologies/fix_parameter_element

Fixed parameter element editor
/main
GitHub 4 年前
当前提交
5c95c242
共有 2 个文件被更改,包括 36 次插入6 次删除
  1. 4
      com.unity.perception/CHANGELOG.md
  2. 38
      com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs

4
com.unity.perception/CHANGELOG.md


Fixed ground truth not properly produced when there are other disabled PerceptionCameras present. Note: this does not yet add support for multiple enabled PerceptionCameras.
Fixed an issue preventing a user from adding more options to a Categorical Parameter's list of options with the 'Add Folder' button. 'Add Folder' now correctly appends the contents of the new folder on the list.
Fixed a bug where uniform probabilities were not properly reset upon adding or removing options from a Categorical Parameter's list of options.
## [0.7.0-preview.2] - 2021-02-08
### Upgrade Notes

38
com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs


listView.style.flexGrow = 1.0f;
listView.style.height = new StyleLength(listView.itemHeight * 4);
var uniformToggle = template.Q<Toggle>("uniform");
VisualElement MakeItem()
{
return new CategoricalOptionElement(

// First delete sets option to null, second delete removes option
var numOptions = optionsProperty.arraySize;
optionsProperty.DeleteArrayElementAtIndex(i);
{
}
void ResetProbabilities()
{
var uniformProbability = probabilitiesProperty.arraySize > 0 ? 1f / probabilitiesProperty.arraySize : 0;
for (var i = 0; i < probabilitiesProperty.arraySize; i++)
{
probabilitiesProperty.GetArrayElementAtIndex(i).floatValue = uniformProbability;
}
}
listView.bindItem = BindItem;
var addOptionButton = template.Q<Button>("add-option");

break;
}
// New items probability will be 0, unless uniform toggle is true
probabilitiesProperty.GetArrayElementAtIndex(probabilitiesProperty.arraySize - 1).floatValue = 0;
if (uniformToggle.value)
ResetProbabilities();
m_SerializedProperty.serializedObject.ApplyModifiedProperties();
listView.itemsSource = categoricalParameter.probabilities;
listView.Refresh();

if (folderPath == string.Empty)
return;
var categories = LoadAssetsFromFolder(folderPath, categoricalParameter.sampleType);
probabilitiesProperty.arraySize += categories.Count;
var optionsIndex = optionsProperty.arraySize;
var uniformProbability = 1f / categories.Count;
probabilitiesProperty.arraySize += categories.Count;
var optionProperty = optionsProperty.GetArrayElementAtIndex(i);
var probabilityProperty = probabilitiesProperty.GetArrayElementAtIndex(i);
var optionProperty = optionsProperty.GetArrayElementAtIndex(optionsIndex + i);
probabilityProperty.floatValue = uniformProbability;
probabilitiesProperty.GetArrayElementAtIndex(i).floatValue = 0;
if (uniformToggle.value)
ResetProbabilities();
m_SerializedProperty.serializedObject.ApplyModifiedProperties();
listView.itemsSource = categoricalParameter.probabilities;

evt.StopImmediatePropagation();
});
var uniformToggle = template.Q<Toggle>("uniform");
var uniformProperty = m_SerializedProperty.FindPropertyRelative("uniform");
uniformToggle.BindProperty(uniformProperty);

正在加载...
取消
保存