浏览代码

refactored randomization uss

/main
Steven Leal 4 年前
当前提交
279a393a
共有 71 个文件被更改,包括 309 次插入320 次删除
  1. 4
      com.unity.perception/Editor/Randomization/Editors/RunInUSimWindow.cs
  2. 7
      com.unity.perception/Editor/Randomization/Uxml/Randomizer/AddRandomizerMenu.uxml
  3. 4
      com.unity.perception/Editor/Randomization/Uxml/Randomizer/MenuDirectoryElement.uxml
  4. 15
      com.unity.perception/Editor/Randomization/Uxml/Randomizer/RandomizerElement.uxml
  5. 4
      com.unity.perception/Editor/Randomization/Uxml/Randomizer/RandomizerList.uxml
  6. 31
      com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml
  7. 16
      com.unity.perception/Editor/Randomization/Uxml/ScenarioBaseElement.uxml
  8. 2
      com.unity.perception/Editor/Randomization/VisualElements/Randomizer/AddRandomizerMenu.cs
  9. 17
      com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs
  10. 8
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
  11. 2
      com.unity.perception/Editor/Randomization/Uxml/Sampler/FloatRangeElement.uxml
  12. 2
      com.unity.perception/Editor/Randomization/VisualElements/Parameter/DrawerParameterElement.cs
  13. 8
      com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs
  14. 2
      com.unity.perception/Editor/Randomization/VisualElements/Parameter/CategoricalOptionElement.cs
  15. 3
      com.unity.perception/Editor/Randomization/VisualElements/Sampler/FloatRangeElement.cs
  16. 3
      com.unity.perception/Editor/Randomization/VisualElements/Sampler/SamplerElement.cs
  17. 14
      com.unity.perception/Editor/Randomization/VisualElements/Randomizer/DragToReorderManipulator.cs
  18. 169
      com.unity.perception/Editor/Randomization/Uss/Styles.uss
  19. 3
      com.unity.perception/Editor/Randomization/Uss/Styles.uss.meta
  20. 3
      com.unity.perception/Editor/Randomization/Uxml/Parameter.meta
  21. 3
      com.unity.perception/Editor/Randomization/Uxml/Sampler.meta
  22. 3
      com.unity.perception/Editor/Randomization/VisualElements/Parameter.meta
  23. 12
      com.unity.perception/Editor/Randomization/VisualElements/Randomizer/RandomizerReorderingIndicator.cs
  24. 3
      com.unity.perception/Editor/Randomization/VisualElements/Sampler.meta
  25. 8
      com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalOptionElement.uxml
  26. 12
      com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalParameterTemplate.uxml
  27. 10
      com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterDrawer.uxml
  28. 6
      com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterElement.uxml
  29. 10
      com.unity.perception/Editor/Randomization/Uxml/Sampler/SamplerElement.uxml
  30. 109
      com.unity.perception/Editor/Randomization/Uss/ParameterStyles.uss
  31. 8
      com.unity.perception/Editor/Randomization/Uss/ParameterStyles.uss.meta
  32. 16
      com.unity.perception/Editor/Randomization/Uss/SamplerStyles.uss
  33. 8
      com.unity.perception/Editor/Randomization/Uss/SamplerStyles.uss.meta
  34. 21
      com.unity.perception/Editor/Randomization/Uss/ScenarioStyles.uss
  35. 3
      com.unity.perception/Editor/Randomization/Uss/ScenarioStyles.uss.meta
  36. 3
      com.unity.perception/Editor/Randomization/Uss/AddRandomizerMenuStyles.uss.meta
  37. 19
      com.unity.perception/Editor/Randomization/Uss/AddRandomizerMenuStyles.uss
  38. 8
      com.unity.perception/Editor/Randomization/Uxml/CategoricalOptionElement.uxml
  39. 12
      com.unity.perception/Editor/Randomization/Uxml/CategoricalParameterTemplate.uxml
  40. 6
      com.unity.perception/Editor/Randomization/Uxml/ParameterElement.uxml
  41. 10
      com.unity.perception/Editor/Randomization/Uxml/SamplerElement.uxml
  42. 10
      com.unity.perception/Editor/Randomization/Uxml/ParameterDrawer.uxml
  43. 12
      com.unity.perception/Editor/Randomization/VisualElements/ParameterDragBar.cs
  44. 0
      /com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalOptionElement.uxml.meta
  45. 0
      /com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalParameterTemplate.uxml.meta
  46. 0
      /com.unity.perception/Editor/Randomization/Uxml/Sampler/FloatRangeElement.uxml
  47. 0
      /com.unity.perception/Editor/Randomization/Uxml/Sampler/FloatRangeElement.uxml.meta
  48. 0
      /com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterElement.uxml.meta
  49. 0
      /com.unity.perception/Editor/Randomization/Uxml/Sampler/SamplerElement.uxml.meta
  50. 0
      /com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterDrawer.uxml.meta
  51. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Parameter/CategoricalOptionElement.cs.meta
  52. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Parameter/ColorHsvaField.cs
  53. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Parameter/ColorHsvaField.cs.meta
  54. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Parameter/DrawerParameterElement.cs
  55. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Parameter/DrawerParameterElement.cs.meta
  56. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Sampler/FloatRangeElement.cs.meta
  57. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Randomizer/RandomizerReorderingIndicator.cs.meta
  58. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs
  59. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs.meta
  60. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Sampler/RandomSeedField.cs.meta
  61. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Sampler/SamplerElement.cs.meta
  62. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Parameter/CategoricalOptionElement.cs
  63. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Sampler/FloatRangeElement.cs
  64. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Sampler/RandomSeedField.cs
  65. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Sampler/SamplerElement.cs
  66. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Randomizer/DragToReorderManipulator.cs.meta
  67. 0
      /com.unity.perception/Editor/Randomization/VisualElements/Randomizer/DragToReorderManipulator.cs

4
com.unity.perception/Editor/Randomization/Editors/RunInUSimWindow.cs


void CreateLinuxBuildAndZip()
{
// Ensure that scenario serialization is enabled
var scenario = (ScenarioBase)m_ScenarioField.value;
scenario.deserializeOnStart = true;
// Create build directory
var pathToProjectBuild = Application.dataPath + "/../" + "Build/";
if (!Directory.Exists(pathToProjectBuild + m_RunNameField.value))

7
com.unity.perception/Editor/Randomization/Uxml/Randomizer/AddRandomizerMenu.uxml


<UXML xmlns="UnityEngine.UIElements">
<VisualElement name="container" style="width: 225px; height: 300px; background-color: #383838; border-width: 1px; border-color: #232323;">
<Style src="../../Uss/AddRandomizerMenuStyles.uss"/>
<TextField name="search-bar" style="padding: 3px;"/>
<Style src="../../Uss/Styles.uss"/>
<TextField name="search-bar" class="randomizer__menu-search-bar" style="padding: 3px;"/>
<VisualElement name="directory-chevron" class="chevron-left"/>
<VisualElement name="directory-chevron" class="randomization__chevron-left"/>
<VisualElement class="randomizer__menu-search-icon"/>
</VisualElement>
</UXML>

4
com.unity.perception/Editor/Randomization/Uxml/Randomizer/MenuDirectoryElement.uxml


<UXML xmlns="UnityEngine.UIElements">
<VisualElement style="flex-direction: row; justify-content: space-between; align-items: center;" class="menu-element">
<VisualElement style="flex-direction: row; justify-content: space-between; align-items: center;" class="randomizer__add-menu-directory-item">
<VisualElement class="chevron-right"/>
<VisualElement class="randomization__chevron-right"/>
</VisualElement>
</UXML>

15
com.unity.perception/Editor/Randomization/Uxml/Randomizer/RandomizerElement.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement class="randomizer-element" style="flex-direction: row;">
<Style src="../Uss/ParameterStyles.uss"/>
<VisualElement name="drag-handle" class="drag-handle"/>
<UXML xmlns="UnityEngine.UIElements">
<VisualElement class="randomizer__element">
<VisualElement name="drag-handle" class="randomizer__drag-handle"/>
<VisualElement name="collapse" class="collapse-toggle foldout-open"/>
<VisualElement name="collapse" class="randomization__collapse-toggle foldout-open"/>
<Button name="remove" class="remove-option-button"/>
<Button name="remove" class="randomization__remove-item-button"/>
<VisualElement name="properties" class="properties-container" style="padding-left: 16px;"/>
<VisualElement name="properties" class="randomization__collapsible-container" style="padding-left: 16px;"/>
</VisualElement>
</VisualElement>
</UXML>

4
com.unity.perception/Editor/Randomization/Uxml/Randomizer/RandomizerList.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement name="randomizers-container" class="dark-viewport" style="margin-top: 6px; min-height: 100px;"/>
<UXML xmlns="UnityEngine.UIElements">
<VisualElement name="randomizers-container" class="scenario__dark-viewport" style="margin-top: 6px; min-height: 100px;"/>
<VisualElement style="flex-direction: row; align-items: center; justify-content: center; margin-top: 4px;">
<Button name="add-randomizer-button" text="Add Randomizer"/>
<Button name="expand-all" text="Expand All"/>

31
com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" xmlns:randEditor="UnityEngine.Perception.Randomization.Editor">
<VisualElement>
<Style src="../Uss/RunInUSimStyles.uss"/>
<VisualElement class="dark-viewport" style="margin-bottom: 20px;">
<VisualElement style="">
<TextField name="run-name" label="Run Name"/>
<editor:IntegerField name="total-iterations" label="Total Iterations"/>
<editor:IntegerField name="instance-count" label="Instance Count" max-value="10000"/>
<editor:ObjectField name="main-scene" label="Main Scene" allow-scene-objects="false"/>
<editor:ObjectField name="scenario" label="Scenario"/>
<VisualElement class="unity-base-field">
<Label text="USim worker config" class="unity-base-field__label"/>
<editor:ToolbarMenu name="sys-param" class="unity-base-field__input" style="border-width: 1px;"/>
</VisualElement>
<VisualElement style="align-items: center;">
<Button name="run-button" text="Build and Run" style="margin: 10px; padding: 2 20; font-size: 13px;"/>
</VisualElement>
</VisualElement>
</VisualElement>
<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<TextField name="run-name" label="Run Name"/>
<editor:IntegerField name="total-iterations" label="Total Iterations"/>
<editor:IntegerField name="instance-count" label="Instance Count" max-value="10000"/>
<editor:ObjectField name="main-scene" label="Main Scene" allow-scene-objects="false"/>
<editor:ObjectField name="scenario" label="Scenario"/>
<VisualElement class="unity-base-field">
<Label text="USim worker config" class="unity-base-field__label"/>
<editor:ToolbarMenu name="sys-param" class="unity-base-field__input" style="border-width: 1px;"/>
</VisualElement>
<VisualElement style="align-items: center;">
<Button name="run-button" text="Build and Run" style="margin: 10px; padding: 2 20; font-size: 13px;"/>
</VisualElement>
</UXML>

16
com.unity.perception/Editor/Randomization/Uxml/ScenarioBaseElement.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement>
<Style src="../Uss/ScenarioStyles.uss"/>
<TextElement class="info-box" text="Scenarios control the execution flow of your simulation by applying randomization parameters. Make sure to always have only one scenario active within your scene."/>
<Style src="../Uss/Styles.uss"/>
<TextElement
class="scenario__info-box"
text="Scenarios control the execution flow of your simulation by applying randomization parameters. Make sure to always have only one scenario active within your scene."/>
<VisualElement name="configuration-container" class="dark-viewport" style="padding-left: 16px">
<VisualElement class="scenario__dark-viewport" style="padding-left: 16px">
<editor:PropertyField binding-path="constants" tooltip="A custom list of parameters for this scenario that will be JSON serialized. You can add or remove constants by modifying the code for this scenario class. Only these properties of the simulation can be changed externally from a built player."/>
<editor:PropertyField
binding-path="constants"
tooltip="A list of parameters for this scenario that will be JSON serialized."/>
<editor:PropertyField tooltip="Read constants from JSON when the application starts" name="deserialize-on-start" label="Deserialize On Start" binding-path="deserializeOnStart"/>
<VisualElement style="flex-direction: row;">
<Button name="serialize-constants" text="Serialize Constants" style="flex-grow: 1;"/>
<Button name="deserialize-constants" text="Deserialize Constants" style="flex-grow: 1;"/>

</VisualElement>
</UXML>

2
com.unity.perception/Editor/Randomization/VisualElements/Randomizer/AddRandomizerMenu.cs


public MenuItemElement(MenuItem menuItem, AddRandomizerMenu menu)
{
text = menuItem.itemName;
AddToClassList("menu-element");
AddToClassList("randomizer__add-menu-directory-item");
RegisterCallback<MouseUpEvent>(evt => menu.AddRandomizer(menuItem.randomizerType));
}
}

17
com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs


/// <exception cref="ScenarioException"></exception>
public override void Deserialize()
{
if (!File.Exists(serializedConstantsFilePath))
throw new ScenarioException($"JSON scenario constants file does not exist at path {serializedConstantsFilePath}");
var jsonText = File.ReadAllText(serializedConstantsFilePath);
constants = JsonUtility.FromJson<T>(jsonText);
if (string.IsNullOrEmpty(serializedConstantsFilePath))
{
Debug.Log("No constants file specified. Running scenario with built in constants.");
}
else if (File.Exists(serializedConstantsFilePath))
{
var jsonText = File.ReadAllText(serializedConstantsFilePath);
constants = JsonUtility.FromJson<T>(jsonText);
}
else
{
Debug.LogWarning($"JSON scenario constants file does not exist at path {serializedConstantsFilePath}");
}
}
}
}

8
com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs


[HideInInspector] public bool quitOnComplete = true;
/// <summary>
/// When true, this scenario will deserializes constants from a Json file before it begins executing
/// </summary>
[HideInInspector] public bool deserializeOnStart;
/// <summary>
/// The name of the Json file this scenario's constants are serialized to/from.
/// </summary>
[HideInInspector] public string serializedConstantsFileName = "constants";

void Start()
{
if (deserializeOnStart)
Deserialize();
Deserialize();
}
void Update()

2
com.unity.perception/Editor/Randomization/Uxml/Sampler/FloatRangeElement.uxml


<VisualElement>
<VisualElement style="flex-direction: row; margin: 1px, 1px, 1px, 3px;">
<Label text="Range" class="unity-base-field__label" style="min-width: 147;"/>
<VisualElement class="float-range" style="flex-grow: 1; flex-direction: row;">
<VisualElement class="sampler__float-range" style="flex-grow: 1; flex-direction: row;">
<editor:FloatField label="Min" tooltip="Minimum" name="minimum" style="flex-grow: 1; flex-shrink: 0; flex-basis: 0; margin-bottom: 0;"/>
<editor:FloatField label="Max" tooltip="Maximum" name="maximum" style="flex-grow: 1; flex-shrink: 0; flex-basis: 0; margin-right: 2px; margin-bottom: 0;"/>
</VisualElement>

2
com.unity.perception/Editor/Randomization/VisualElements/Parameter/DrawerParameterElement.cs


m_Collapsed = property.FindPropertyRelative("collapsed");
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{StaticData.uxmlDir}/ParameterDrawer.uxml").CloneTree(this);
$"{StaticData.uxmlDir}/Parameter/ParameterDrawer.uxml").CloneTree(this);
var collapseToggle = this.Q<VisualElement>("collapse");
collapseToggle.RegisterCallback<MouseUpEvent>(evt => collapsed = !collapsed);

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


public ParameterElement(SerializedProperty property)
{
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{StaticData.uxmlDir}/ParameterElement.uxml");
$"{StaticData.uxmlDir}/Parameter/ParameterElement.uxml");
template.CloneTree(this);
m_SerializedProperty = property;
m_PropertiesContainer = this.Q<VisualElement>("properties");

void CreateCategoricalParameterFields()
{
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{StaticData.uxmlDir}/CategoricalParameterTemplate.uxml").CloneTree();
$"{StaticData.uxmlDir}/Parameter/CategoricalParameterTemplate.uxml").CloneTree();
var optionsProperty = m_SerializedProperty.FindPropertyRelative("m_Categories");
var probabilitiesProperty = m_SerializedProperty.FindPropertyRelative("probabilities");

void ToggleProbabilityFields(bool toggle)
{
if (toggle)
listView.AddToClassList("uniform-probability");
listView.AddToClassList("collapsed");
listView.RemoveFromClassList("uniform-probability");
listView.RemoveFromClassList("collapsed");
}
ToggleProbabilityFields(uniformToggle.value);
if (Application.isPlaying)

2
com.unity.perception/Editor/Randomization/VisualElements/Parameter/CategoricalOptionElement.cs


m_ProbabilitiesProperty = probabilitiesProperty;
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{StaticData.uxmlDir}/CategoricalOptionElement.uxml");
$"{StaticData.uxmlDir}/Parameter/CategoricalOptionElement.uxml");
template.CloneTree(this);
}

3
com.unity.perception/Editor/Randomization/VisualElements/Sampler/FloatRangeElement.cs


{
public FloatRangeElement(SerializedProperty property)
{
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>($"{StaticData.uxmlDir}/FloatRangeElement.uxml");
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{StaticData.uxmlDir}/Sampler/FloatRangeElement.uxml");
template.CloneTree(this);
var minimumField = this.Q<FloatField>("minimum");

3
com.unity.perception/Editor/Randomization/VisualElements/Sampler/SamplerElement.cs


public SamplerElement(SerializedProperty property, Parameter parameter)
{
m_Property = property;
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>($"{StaticData.uxmlDir}/SamplerElement.uxml");
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{StaticData.uxmlDir}/Sampler/SamplerElement.uxml");
template.CloneTree(this);
m_Parameter = parameter;

14
com.unity.perception/Editor/Randomization/VisualElements/Randomizer/DragToReorderManipulator.cs


float m_Offset;
RandomizerElement m_RandomizerElement;
VisualElement m_DragHandle;
VisualElement m_DragBar;
VisualElement m_ReorderingIndicator;
VisualElement m_ParameterContainer;
protected override void RegisterCallbacksOnTarget()

}
m_ParameterContainer = target.parent;
m_DragBar = new ParameterDragBar();
m_DragBar.style.width = new StyleLength(m_ParameterContainer.resolvedStyle.width);
target.parent.Add(m_DragBar);
m_ReorderingIndicator = new RandomizerReorderingIndicator();
m_ReorderingIndicator.style.width = new StyleLength(m_ParameterContainer.resolvedStyle.width);
target.parent.Add(m_ReorderingIndicator);
m_DragBar.style.top = evt.localMousePosition.y + m_Offset;
m_ReorderingIndicator.style.top = evt.localMousePosition.y + m_Offset;
m_Active = true;
m_DragHandle.CaptureMouse();

if (!m_Active || !m_DragHandle.HasMouseCapture())
return;
m_DragBar.style.top = evt.localMousePosition.y + m_Offset;
m_ReorderingIndicator.style.top = evt.localMousePosition.y + m_Offset;
evt.StopPropagation();
}

return;
var dragBarY = evt.localMousePosition.y + m_Offset;
m_DragBar.RemoveFromHierarchy();
m_ReorderingIndicator.RemoveFromHierarchy();
m_Active = false;
m_DragHandle.ReleaseMouse();

169
com.unity.perception/Editor/Randomization/Uss/Styles.uss


/* General randomization classes */
.randomization__remove-item-button {
width: 12px;
height: 14px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/X.png");
}
.randomization__collapse-toggle {
flex-shrink: 0;
margin-right: 3px;
margin-left: 3px;
width: 10px;
height: 10px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/FoldoutOpen.png");
}
.collapsed .randomization__collapse-toggle {
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/FoldoutClosed.png");
}
.randomization__collapse-toggle:hover {
-unity-background-image-tint-color: cornflowerblue;
}
.collapsed .randomization__collapsible-container {
display: none;
}
.randomization__chevron-left {
height: 12px;
width: 12px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/ChevronLeft.png");
}
.randomization__chevron-right {
height: 12px;
width: 12px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/ChevronRight.png");
}
/* Scenario classes */
.scenario__info-box {
border-width: 1px;
border-color: #191919;
padding: 2px 4px 2px 4px;
white-space: normal;
margin-top: 4px;
margin-bottom: 4px;
}
.scenario__dark-viewport {
border-radius: 5px;
background-color: #191919;
padding: 2px;
}
/* Randomizer classes */
.randomizer__drag-bar {
width: 100px;
height: 6px;
background-color: rgba(100,149,237,0.4);
position: absolute;
}
.randomizer__element {
border-width: 2px;
border-radius: 5px;
margin: 2px 1px;
background-color: #383838;
flex-direction: row;
}
.randomizer__drag-handle {
flex-shrink: 0;
width: 16px;
height: 100%;
min-height: 20px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/DragHandle.png");
}
.randomizer__drag-handle:hover {
-unity-background-image-tint-color: black;
}
.randomizer__add-menu-directory-item {
padding: 2px 10px 2px 20px;
}
.randomizer__add-menu-directory-item:hover {
background-color: #3E5F96;
}
.randomizer__reordering-hover-indicator {
width: 100px;
height: 6px;
background-color: rgba(100,149,237,0.4);
position: absolute;
}
.randomizer__menu-search-icon {
position: absolute;
left: 10px;
top: 9px;
width: 10px;
height: 10px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/Search.png");
}
.randomizer__menu-search-bar .unity-base-text-field__input {
padding-left: 15px;
}
/* Parameter classes */
.parameter__categorical-option {
flex-direction: row;
background-color: #3F3F3F;
margin: 1px;
border-radius: 4px;
}
.parameter__categorical-options-list {
background-color: #191919;
border-radius: 4px;
margin-right: 2px;
padding: 3px;
border-bottom-right-radius: 0;
}
.parameter__categorical-option-property-field {
width: 0;
flex-grow: 1;
flex-shrink: 0;
}
.parameter__categorical-options-list-button {
align-self: flex-end;
border-width: 0;
border-top-right-radius: 0;
border-top-left-radius: 0;
background-color: #191919;
margin-top: 0;
margin-right: 2px;
}
.parameter__categorical-options-list-button:hover {
background-color: #2A2A2A;
}
.parameter__categorical-options-list-button:active {
color: cornflowerblue;
}
/* Sampler classes */
.sampler__type-menu {
flex-grow: 1.5;
border-radius: 3px;
border-width: 1px;
margin-top: 2px;
margin-right: 3px;
}
.sampler__float-range .unity-base-field__label {
min-width: auto;
margin-right: 4px;
}

3
com.unity.perception/Editor/Randomization/Uss/Styles.uss.meta


fileFormatVersion: 2
guid: a3321de444a246f59e8a0445d5d2bf5d
timeCreated: 1601665266

3
com.unity.perception/Editor/Randomization/Uxml/Parameter.meta


fileFormatVersion: 2
guid: 9dff455d50ac4549bac301eb5926c83c
timeCreated: 1601668963

3
com.unity.perception/Editor/Randomization/Uxml/Sampler.meta


fileFormatVersion: 2
guid: cdf29c5fa139470d961ca4605d792f0a
timeCreated: 1601668985

3
com.unity.perception/Editor/Randomization/VisualElements/Parameter.meta


fileFormatVersion: 2
guid: 198e373f78464aa7a4bf4211e82434dc
timeCreated: 1601669088

12
com.unity.perception/Editor/Randomization/VisualElements/Randomizer/RandomizerReorderingIndicator.cs


using UnityEngine.UIElements;
namespace UnityEngine.Experimental.Perception.Randomization.Editor
{
class RandomizerReorderingIndicator : VisualElement
{
public RandomizerReorderingIndicator()
{
AddToClassList("randomizer__reordering-hover-indicator");
}
}
}

3
com.unity.perception/Editor/Randomization/VisualElements/Sampler.meta


fileFormatVersion: 2
guid: 650bdb8ee9ab42f99509974c7a076e00
timeCreated: 1601669132

8
com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalOptionElement.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement class="parameter__categorical-option">
<Button name="remove" class="randomization__remove-item-button"/>
<Label name="index-label" text="[0]" style="min-width: 50px;"/>
<editor:PropertyField name="option" class="parameter__categorical-option-property-field"/>
<editor:FloatField label="p:" name="probability" tooltip="Probability" class="randomization__collapsible-container" style="min-width: 40px; flex-grow: 0.15;"/>
</VisualElement>
</UXML>

12
com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalParameterTemplate.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<Toggle label="Uniform" name="uniform"/>
<editor:IntegerField label="Seed" name="seed"/>
<VisualElement class="parameter__categorical-options-list">
<ListView name="options"/>
</VisualElement>
<VisualElement style="flex-direction: row; justify-content: flex-end;">
<Button name="add-option" text="Add Option" class="parameter__categorical-options-list-button"/>
<Button name="add-folder" text="Add Folder" class="parameter__categorical-options-list-button"/>
<Button name="clear-options" text="Clear Options" class="parameter__categorical-options-list-button"/>
</VisualElement>
</UXML>

10
com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterDrawer.uxml


<UXML xmlns="UnityEngine.UIElements">
<VisualElement>
<Style src="../../Uss/Styles.uss"/>
<VisualElement style="flex-direction: row; align-items: center;">
<VisualElement name="collapse" class="randomization__collapse-toggle foldout-open"/>
<Label name="field-name" style="font-size: 12px;"/>
</VisualElement>
<VisualElement name="drawer" class="randomization__collapsible-container" style="padding-left: 18px;"/>
</VisualElement>
</UXML>

6
com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterElement.uxml


<UXML xmlns="UnityEngine.UIElements">
<VisualElement>
<Style src="../../Uss/Styles.uss"/>
<VisualElement name="properties"/>
</VisualElement>
</UXML>

10
com.unity.perception/Editor/Randomization/Uxml/Sampler/SamplerElement.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement name="sampler-template" style="margin-bottom: 4px;">
<Style src="../../Uss/Styles.uss"/>
<VisualElement style="flex-direction: row; align-items: center;">
<Label name="sampler-name" text="Sampler Name" class="unity-base-field__label"/>
<editor:ToolbarMenu name="sampler-type-dropdown" text="Placeholder Sampler Type" class="sampler__type-menu"/>
</VisualElement>
<VisualElement name="fields-container" style="margin-left: 18px;"/>
</VisualElement>
</UXML>

109
com.unity.perception/Editor/Randomization/Uss/ParameterStyles.uss


.randomizer-element {
border-width: 2px;
border-radius: 5px;
margin: 2px 1px;
background-color: #383838;
}
.parameter-type-label-container {
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 1px;
}
.parameter-type-label-box {
flex-direction: row;
align-items: center;
justify-content: flex-start;
flex-grow: 0;
-unity-text-align: middle-center;
border-width: 0;
padding: 1px;
font-size: 13px;
}
.parameter-type-label {
color: cornflowerblue;
-unity-text-align: middle-left;
margin-right: 4px;
}
.parameter-type-label-box .unity-base-text-field__input {
padding-left: 6px;
padding-right: 6px;
}
.collapse-toggle {
flex-shrink: 0;
margin-right: 3px;
margin-left: 3px;
width: 12px;
height: 12px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/FoldoutOpen.png");
}
.collapsed .collapse-toggle {
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/FoldoutClosed.png");
}
.collapsed .properties-container {
display: none;
}
.categorical-option {
flex-direction: row;
background-color: #3F3F3F;
margin: 1px;
border-radius: 4px;
}
.options-list-view {
background-color: #191919;
border-radius: 4px;
margin-right: 2px;
padding: 3px;
border-bottom-right-radius: 0;
}
.option-property-field {
width: 0;
flex-grow: 1;
flex-shrink: 0;
}
.uniform-probability .hide-when-uniform {
display: none;
}
.add-option-button {
align-self: flex-end;
border-width: 0;
border-top-right-radius: 0;
border-top-left-radius: 0;
background-color: #191919;
margin-top: 0;
margin-right: 2px;
}
.add-option-button:hover {
background-color: #2A2A2A;
}
.add-option-button:active {
color: cornflowerblue;
}
.remove-option-button {
width: 12px;
height: 14px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/X.png");
}
.drag-handle {
flex-shrink: 0;
width: 16px;
height: 100%;
min-height: 20px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/DragHandle.png");
}

8
com.unity.perception/Editor/Randomization/Uss/ParameterStyles.uss.meta


fileFormatVersion: 2
<<<<<<< HEAD
guid: 0a4e5cce05674cabb4e35dbba3176bb0
timeCreated: 1600754588
=======
guid: def81fa16f8b41aca393a30c3b1fac72
timeCreated: 1598222679
>>>>>>> 86d25d2... implemented parameter behaviours

16
com.unity.perception/Editor/Randomization/Uss/SamplerStyles.uss


.sampler-type-menu {
flex-grow: 1.5;
border-radius: 3px;
border-width: 1px;
margin-top: 2px;
margin-right: 3px;
}
.sampler-name {
/*color: lightgreen;*/
}
.float-range .unity-base-field__label {
min-width: auto;
margin-right: 4px;
}

8
com.unity.perception/Editor/Randomization/Uss/SamplerStyles.uss.meta


fileFormatVersion: 2
<<<<<<< HEAD
guid: f96184638ee64ea18b5e2d5c90f94c67
timeCreated: 1600754588
=======
guid: 85ff041b142f41798a7703bda9bb1ba7
timeCreated: 1598222791
>>>>>>> 86d25d2... implemented parameter behaviours

21
com.unity.perception/Editor/Randomization/Uss/ScenarioStyles.uss


.dark-viewport {
border-radius: 5px;
background-color: #191919;
padding: 2px;
}
.info-box {
border-width: 1px;
border-color: #191919;
padding: 2px 4px 2px 4px;
white-space: normal;
margin-top: 4px;
margin-bottom: 4px;
}
.drag-bar {
width: 100px;
height: 6px;
background-color: rgba(100,149,237,0.4);
position: absolute;
}

3
com.unity.perception/Editor/Randomization/Uss/ScenarioStyles.uss.meta


fileFormatVersion: 2
guid: 7db846b4c7cf420e8fdc32c7f701f5c3
timeCreated: 1600276536

3
com.unity.perception/Editor/Randomization/Uss/AddRandomizerMenuStyles.uss.meta


fileFormatVersion: 2
guid: 4315140b032047f8ad6bce89e3653dce
timeCreated: 1600837395

19
com.unity.perception/Editor/Randomization/Uss/AddRandomizerMenuStyles.uss


.menu-element {
padding: 2px 10px 2px 20px;
}
.chevron-right {
height: 12px;
width: 12px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/ChevronRight.png");
}
.chevron-left {
height: 12px;
width: 12px;
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/ChevronLeft.png");
}
.menu-element:hover {
background-color: #3E5F96;
}

8
com.unity.perception/Editor/Randomization/Uxml/CategoricalOptionElement.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement class="categorical-option">
<Button name="remove" class="remove-option-button"/>
<Label name="index-label" text="[0]" style="min-width: 50px;"/>
<editor:PropertyField name="option" class="option-property-field"/>
<editor:FloatField label="p:" name="probability" tooltip="Probability" class="hide-when-uniform" style="min-width: 40px; flex-grow: 0.15;"/>
</VisualElement>
</UXML>

12
com.unity.perception/Editor/Randomization/Uxml/CategoricalParameterTemplate.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<Toggle label="Uniform" name="uniform"/>
<editor:IntegerField label="Seed" name="seed"/>
<VisualElement class="options-list-view">
<ListView name="options"/>
</VisualElement>
<VisualElement style="flex-direction: row; justify-content: flex-end;">
<Button name="add-option" text="Add Option" class="add-option-button"/>
<Button name="add-folder" text="Add Folder" class="add-option-button"/>
<Button name="clear-options" text="Clear Options" class="add-option-button"/>
</VisualElement>
</UXML>

6
com.unity.perception/Editor/Randomization/Uxml/ParameterElement.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement>
<Style src="../Uss/ParameterStyles.uss"/>
<VisualElement name="properties"/>
</VisualElement>
</UXML>

10
com.unity.perception/Editor/Randomization/Uxml/SamplerElement.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement name="sampler-template" style="margin-bottom: 4px;">
<Style src="../Uss/SamplerStyles.uss"/>
<VisualElement style="flex-direction: row; align-items: center;">
<Label name="sampler-name" text="Sampler Name" class="unity-base-field__label sampler-name"/>
<editor:ToolbarMenu name="sampler-type-dropdown" text="Placeholder Sampler Type" class="sampler-type-menu"/>
</VisualElement>
<VisualElement name="fields-container" style="margin-left: 18px;"/>
</VisualElement>
</UXML>

10
com.unity.perception/Editor/Randomization/Uxml/ParameterDrawer.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement>
<Style src="../Uss/ParameterStyles.uss"/>
<VisualElement style="flex-direction: row; align-items: center;">
<VisualElement name="collapse" class="collapse-toggle foldout-open"/>
<Label name="field-name" style="font-size: 12px;"/>
</VisualElement>
<VisualElement name="drawer" class="properties-container" style="padding-left: 18px;"/>
</VisualElement>
</UXML>

12
com.unity.perception/Editor/Randomization/VisualElements/ParameterDragBar.cs


using UnityEngine.UIElements;
namespace UnityEngine.Experimental.Perception.Randomization.Editor
{
class ParameterDragBar : VisualElement
{
public ParameterDragBar()
{
AddToClassList("drag-bar");
}
}
}

/com.unity.perception/Editor/Randomization/Uxml/CategoricalOptionElement.uxml.meta → /com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalOptionElement.uxml.meta

/com.unity.perception/Editor/Randomization/Uxml/CategoricalParameterTemplate.uxml.meta → /com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalParameterTemplate.uxml.meta

/com.unity.perception/Editor/Randomization/Uxml/FloatRangeElement.uxml → /com.unity.perception/Editor/Randomization/Uxml/Sampler/FloatRangeElement.uxml

/com.unity.perception/Editor/Randomization/Uxml/FloatRangeElement.uxml.meta → /com.unity.perception/Editor/Randomization/Uxml/Sampler/FloatRangeElement.uxml.meta

/com.unity.perception/Editor/Randomization/Uxml/ParameterElement.uxml.meta → /com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterElement.uxml.meta

/com.unity.perception/Editor/Randomization/Uxml/SamplerElement.uxml.meta → /com.unity.perception/Editor/Randomization/Uxml/Sampler/SamplerElement.uxml.meta

/com.unity.perception/Editor/Randomization/Uxml/ParameterDrawer.uxml.meta → /com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterDrawer.uxml.meta

/com.unity.perception/Editor/Randomization/VisualElements/CategoricalOptionElement.cs.meta → /com.unity.perception/Editor/Randomization/VisualElements/Parameter/CategoricalOptionElement.cs.meta

/com.unity.perception/Editor/Randomization/VisualElements/ColorHsvaField.cs → /com.unity.perception/Editor/Randomization/VisualElements/Parameter/ColorHsvaField.cs

/com.unity.perception/Editor/Randomization/VisualElements/ColorHsvaField.cs.meta → /com.unity.perception/Editor/Randomization/VisualElements/Parameter/ColorHsvaField.cs.meta

/com.unity.perception/Editor/Randomization/VisualElements/DrawerParameterElement.cs → /com.unity.perception/Editor/Randomization/VisualElements/Parameter/DrawerParameterElement.cs

/com.unity.perception/Editor/Randomization/VisualElements/DrawerParameterElement.cs.meta → /com.unity.perception/Editor/Randomization/VisualElements/Parameter/DrawerParameterElement.cs.meta

/com.unity.perception/Editor/Randomization/VisualElements/FloatRangeElement.cs.meta → /com.unity.perception/Editor/Randomization/VisualElements/Sampler/FloatRangeElement.cs.meta

/com.unity.perception/Editor/Randomization/VisualElements/ParameterDragBar.cs.meta → /com.unity.perception/Editor/Randomization/VisualElements/Randomizer/RandomizerReorderingIndicator.cs.meta

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

/com.unity.perception/Editor/Randomization/VisualElements/ParameterElement.cs.meta → /com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs.meta

/com.unity.perception/Editor/Randomization/VisualElements/RandomSeedField.cs.meta → /com.unity.perception/Editor/Randomization/VisualElements/Sampler/RandomSeedField.cs.meta

/com.unity.perception/Editor/Randomization/VisualElements/SamplerElement.cs.meta → /com.unity.perception/Editor/Randomization/VisualElements/Sampler/SamplerElement.cs.meta

/com.unity.perception/Editor/Randomization/VisualElements/CategoricalOptionElement.cs → /com.unity.perception/Editor/Randomization/VisualElements/Parameter/CategoricalOptionElement.cs

/com.unity.perception/Editor/Randomization/VisualElements/FloatRangeElement.cs → /com.unity.perception/Editor/Randomization/VisualElements/Sampler/FloatRangeElement.cs

/com.unity.perception/Editor/Randomization/VisualElements/RandomSeedField.cs → /com.unity.perception/Editor/Randomization/VisualElements/Sampler/RandomSeedField.cs

/com.unity.perception/Editor/Randomization/VisualElements/SamplerElement.cs → /com.unity.perception/Editor/Randomization/VisualElements/Sampler/SamplerElement.cs

/com.unity.perception/Editor/Randomization/VisualElements/DragToReorderManipulator.cs.meta → /com.unity.perception/Editor/Randomization/VisualElements/Randomizer/DragToReorderManipulator.cs.meta

/com.unity.perception/Editor/Randomization/VisualElements/DragToReorderManipulator.cs → /com.unity.perception/Editor/Randomization/VisualElements/Randomizer/DragToReorderManipulator.cs

正在加载...
取消
保存