比较提交

...
此合并请求有变更与目标分支冲突。
/com.unity.perception/Editor/Unity.Perception.Editor.asmdef
/com.unity.perception/Editor/Randomization
/com.unity.perception/Runtime/Randomization
/com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs.meta
/com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs.meta

4 次代码提交

作者 SHA1 备注 提交日期
Steven Leal 6dfc79e8 updated meta files 4 年前
Steven Leal 53ed3744 using CloneTree() instead of Instantiate() 4 年前
Steven Leal c2b11b74 tested reflection.emit 4 年前
Steven Leal 3d6c7436 added parameter uielements prototype ui 4 年前
共有 115 个文件被更改,包括 1490 次插入1 次删除
  1. 3
      com.unity.perception/Editor/Unity.Perception.Editor.asmdef
  2. 8
      com.unity.perception/Editor/Randomization.meta
  3. 8
      com.unity.perception/Runtime/Randomization.meta
  4. 11
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs.meta
  5. 11
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs.meta
  6. 11
      com.unity.perception/Editor/Randomization/ParameterConfigurationEditor.cs.meta
  7. 3
      com.unity.perception/Editor/Randomization/Uss.meta
  8. 126
      com.unity.perception/Editor/Randomization/Uss/Styles.uss
  9. 3
      com.unity.perception/Editor/Randomization/Uss/Styles.uss.meta
  10. 3
      com.unity.perception/Editor/Randomization/Uxml.meta
  11. 30
      com.unity.perception/Editor/Randomization/Uxml/ParameterConfiguration.uxml
  12. 10
      com.unity.perception/Editor/Randomization/Uxml/ParameterConfiguration.uxml.meta
  13. 36
      com.unity.perception/Editor/Randomization/Uxml/ParameterTemplate.uxml
  14. 3
      com.unity.perception/Editor/Randomization/Uxml/ParameterTemplate.uxml.meta
  15. 311
      com.unity.perception/Editor/Randomization/ParameterConfigurationEditor.cs
  16. 8
      com.unity.perception/Runtime/Randomization/Parameters.meta
  17. 8
      com.unity.perception/Runtime/Randomization/Parameters/Abstractions.meta
  18. 8
      com.unity.perception/Runtime/Randomization/Parameters/MonoBehaviours.meta
  19. 8
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes.meta
  20. 9
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/BooleanParameter.cs
  21. 3
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/BooleanParameter.cs.meta
  22. 10
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/ColorParameter.cs
  23. 3
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/ColorParameter.cs.meta
  24. 11
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/FloatParameter.cs
  25. 11
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/FloatParameter.cs.meta
  26. 11
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/IntParameter.cs
  27. 3
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/IntParameter.cs.meta
  28. 9
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/StringParameter.cs
  29. 3
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/StringParameter.cs.meta
  30. 10
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/Vector3Parameter.cs
  31. 3
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/Vector3Parameter.cs.meta
  32. 11
      com.unity.perception/Runtime/Randomization/Parameters/Abstractions/Parameter.cs.meta
  33. 47
      com.unity.perception/Runtime/Randomization/Parameters/Abstractions/ParameterBase.cs
  34. 3
      com.unity.perception/Runtime/Randomization/Parameters/Abstractions/ParameterBase.cs.meta
  35. 102
      com.unity.perception/Runtime/Randomization/Parameters/Abstractions/Parameter.cs
  36. 11
      com.unity.perception/Runtime/Randomization/Parameters/MonoBehaviours/ParameterConfiguration.cs.meta
  37. 131
      com.unity.perception/Runtime/Randomization/Parameters/MonoBehaviours/ParameterConfiguration.cs
  38. 8
      com.unity.perception/Runtime/Randomization/Samplers.meta
  39. 8
      com.unity.perception/Runtime/Randomization/Samplers/Abstractions.meta
  40. 3
      com.unity.perception/Runtime/Randomization/Samplers/BooleanSamplers.meta
  41. 16
      com.unity.perception/Runtime/Randomization/Samplers/BooleanSamplers/FixedBooleanSampler.cs
  42. 3
      com.unity.perception/Runtime/Randomization/Samplers/BooleanSamplers/FixedBooleanSampler.cs.meta
  43. 3
      com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers.meta
  44. 16
      com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/FixedColorSampler.cs
  45. 3
      com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/FixedColorSampler.cs.meta
  46. 27
      com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/GridColorSampler.cs
  47. 3
      com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/GridColorSampler.cs.meta
  48. 22
      com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/RandomUniformColorSampler.cs
  49. 3
      com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/RandomUniformColorSampler.cs.meta
  50. 8
      com.unity.perception/Runtime/Randomization/Samplers/Enums.meta
  51. 7
      com.unity.perception/Runtime/Randomization/Samplers/Enums/IterationOrigin.cs
  52. 11
      com.unity.perception/Runtime/Randomization/Samplers/Enums/IterationOrigin.cs.meta
  53. 8
      com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers.meta
  54. 16
      com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/FixedFloatSampler.cs
  55. 11
      com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/FixedFloatSampler.cs.meta
  56. 22
      com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/GridFloatSampler.cs
  57. 11
      com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/GridFloatSampler.cs.meta
  58. 18
      com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/RandomUniformFloatSampler.cs
  59. 11
      com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/RandomUniformFloatSampler.cs.meta
  60. 3
      com.unity.perception/Runtime/Randomization/Samplers/IntSamplers.meta
  61. 16
      com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/FixedIntSampler.cs
  62. 3
      com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/FixedIntSampler.cs.meta
  63. 23
      com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/GridIntSampler.cs
  64. 3
      com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/GridIntSampler.cs.meta
  65. 18
      com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/RandomUniformIntSampler.cs
  66. 3
      com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/RandomUniformIntSampler.cs.meta
  67. 3
      com.unity.perception/Runtime/Randomization/Samplers/StringSamplers.meta
  68. 16
      com.unity.perception/Runtime/Randomization/Samplers/StringSamplers/FixedStringSampler.cs
  69. 3
      com.unity.perception/Runtime/Randomization/Samplers/StringSamplers/FixedStringSampler.cs.meta
  70. 3
      com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers.meta
  71. 16
      com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/FixedVector3Sampler.cs
  72. 3
      com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/FixedVector3Sampler.cs.meta
  73. 21
      com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/GridVector3Sampler.cs
  74. 3
      com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/GridVector3Sampler.cs.meta
  75. 18
      com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/RandomUniformVector3Sampler.cs
  76. 3
      com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/RandomUniformVector3Sampler.cs.meta
  77. 42
      com.unity.perception/Runtime/Randomization/Samplers/Abstractions/RandomSampler.cs
  78. 3
      com.unity.perception/Runtime/Randomization/Samplers/Abstractions/RandomSampler.cs.meta
  79. 15
      com.unity.perception/Runtime/Randomization/Samplers/Abstractions/Sampler.cs
  80. 11
      com.unity.perception/Runtime/Randomization/Samplers/Abstractions/Sampler.cs.meta
  81. 3
      com.unity.perception/Runtime/Randomization/Samplers/Abstractions/SamplerBase.cs.meta
  82. 13
      com.unity.perception/Runtime/Randomization/Samplers/Abstractions/SamplerBase.cs
  83. 8
      com.unity.perception/Runtime/Randomization/Scenarios.meta

3
com.unity.perception/Editor/Unity.Perception.Editor.asmdef


"Unity.Collections",
"Unity.Perception.Runtime",
"PathCreatorEditor",
"PathCreator"
"PathCreator",
"UnityEngine.UI"
],
"includePlatforms": [
"Editor"

8
com.unity.perception/Editor/Randomization.meta


fileFormatVersion: 2
guid: bc1c8d85f0374514ab4d1af6b3bbe6cd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Runtime/Randomization.meta


fileFormatVersion: 2
guid: 511b2251e3510cd48a26b8a61f6911f0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs.meta


fileFormatVersion: 2
guid: ca435be344b89eb4b98ee59610a8bfde
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs.meta


fileFormatVersion: 2
guid: eb9132b1c1496144e81b3090b62af8af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.perception/Editor/Randomization/ParameterConfigurationEditor.cs.meta


fileFormatVersion: 2
guid: dd62abede5784c84f90495b367408ced
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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


fileFormatVersion: 2
guid: fcf9d543882d491e9b2c1e9a32f18763
timeCreated: 1590479034

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


.dark-viewport {
border-radius: 5px;
background-color: #191919;
padding: 2px;
}
.parameter-container-scroll {
min-height: 100px;
max-height: 600px;
}
.parameter-container {
flex-shrink: 0;
}
.parameter-properties-box {
border-width: 2px;
border-radius: 5px;
flex-direction: row;
margin: 2px 1px;
}
.parameter-properties-container {
flex-grow: 1;
}
.parameter-type-menu {
flex-grow: 2;
border-width: 2px;
border-radius: 5px;
background-color: #585858;
}
#parameter-type-menu .unity-toolbar-menu__text {
-unity-text-align: middle-center;
font-size: 13px;
-unity-font-style: bold;
padding: 3px;
}
.sampler-type-menu {
flex-grow: 1.5;
border-radius: 3px;
border-width: 1px;
padding-bottom: 1px;
margin-bottom: 1px;
margin-right: 1px;
}
.parameter-type-label-container {
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 1px;
}
.parameter-type-label-box {
flex-direction: row;
flex-grow: 0;
-unity-text-align: middle-center;
border-width: 0;
padding: 1px 13px;
font-size: 13px;
-unity-font-style: bold;
}
.parameter-type-label {
color: cornflowerblue;
}
.parameter-type-label-box .unity-base-text-field__input {
padding-left: 6px;
padding-right: 6px;
}
.unity-toggle {
margin-left: 0;
}
.property-selection-container {
flex-direction: row;
}
.property-select-menu {
flex-grow: 1;
border-width: 1px;
padding-bottom: 1px;
border-radius: 3px;
margin-right: 1px;
}
.remove-parameter-button {
background-image: resource("Packages/com.unity.collab-proxy/Editor/Assets/Icons/clear-dark.png");
}
.move-buttons-container {
margin-right: 6px;
width: 28px;
border-color: black;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
background-color: #2A2A2A;
justify-content: space-between;
align-items: center;
padding: 3px 0;
}
.move-button-up {
background-image: resource("Packages/com.unity.shadergraph/Editor/Resources/GraphView/Nodes/NodeChevronUp.png");
}
.move-button-down {
background-image: resource("Packages/com.unity.shadergraph/Editor/Resources/GraphView/Nodes/NodeChevronDown.png");
}
.small-icon {
border-width: 0;
width: 16px;
height: 16px;
padding: 9px;
}
.unity-imgui-container {
margin-left: 1px;
margin-right: 3px;
}

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


fileFormatVersion: 2
guid: 5e1a10e7ee7a46898d0138a9d08615ee
timeCreated: 1589577216

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


fileFormatVersion: 2
guid: 36c3e81fb3034cce8b3f05ceac6bae70
timeCreated: 1590479019

30
com.unity.perception/Editor/Randomization/Uxml/ParameterConfiguration.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement>
<Style src="../Uss/Styles.uss"/>
<Label text="Parameters" style="font-size: 20px; -unity-text-align: middle-center;"/>
<ScrollView show-vertical-scroller="true" name="parameter-viewport" class="dark-viewport parameter-container-scroll">
<VisualElement name="parameter-container" class="parameter-container">
</VisualElement>
</ScrollView>
<VisualElement style="flex-direction: row; justify-content: space-between;">
<VisualElement style="flex-grow: 1"/>
<editor:ToolbarMenu text="Add New Parameter" name="parameter-type-menu" class="parameter-type-menu"/>
<VisualElement style="flex-grow: 1"/>
</VisualElement>
<Label text="Runtime" style="margin-top: 20px; font-size: 20px; -unity-text-align: middle-center;"/>
<VisualElement name="configuration-container" class="dark-viewport">
<editor:PropertyField name="scenario-field" text="Scenario" binding-path="scenario"/>
<VisualElement class="unity-base-field">
<Label text="Total Iteration Count" class="unity-base-field__label"/>
<Label name="total-iteration-count-label" text="0"/>
</VisualElement>
<VisualElement class="unity-base-field">
<Label text="Total Frame Count" class="unity-base-field__label"/>
<Label name="total-frame-count-label" text="0"/>
</VisualElement>
</VisualElement>
</VisualElement>
</UXML>

10
com.unity.perception/Editor/Randomization/Uxml/ParameterConfiguration.uxml.meta


fileFormatVersion: 2
guid: 6b8a21614fbae12468cb42ada0df200f
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}

36
com.unity.perception/Editor/Randomization/Uxml/ParameterTemplate.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<Box name="parameter-properties-box" class="parameter-properties-box">
<VisualElement class="move-buttons-container">
<Button name="move-up-button" class="small-icon move-button-up"/>
<Button name="move-down-button" class="small-icon move-button-down"/>
</VisualElement>
<VisualElement class="parameter-properties-container">
<VisualElement class="parameter-type-label-container">
<VisualElement/>
<Box class="parameter-type-label-box">
<Label name="parameter-type-label" text="Type:" class="parameter-type-label"/>
<TextField binding-path="parameterName" name="parameter-name" text="Parameter Name" class="parameter-name-field"/>
</Box>
<Button name="remove-parameter" class="small-icon remove-parameter-button"/>
</VisualElement>
<VisualElement class="unity-base-field">
<Label text="Apply To Target" class="unity-base-field__label"/>
<Toggle binding-path="hasTarget" name="has-target-toggle"/>
</VisualElement>
<VisualElement name="target-container" class="unity-foldout__content">
<editor:PropertyField binding-path="target" name="target-field" label="Target Object"/>
<VisualElement class="unity-base-field">
<Label text="Property" class="unity-base-field__label"/>
<editor:ToolbarMenu text="Select A Property" name="property-select-menu" class="property-select-menu"/>
</VisualElement>
</VisualElement>
<VisualElement class="unity-base-field">
<Label text="Sampler Type" class="unity-base-field__label"/>
<editor:ToolbarMenu text="Placeholder Sampler Type" name="sampler-type-dropdown" class="sampler-type-menu"/>
</VisualElement>
<VisualElement name="sampler-fields-container"/>
</VisualElement>
</Box>
</UXML>

3
com.unity.perception/Editor/Randomization/Uxml/ParameterTemplate.uxml.meta


fileFormatVersion: 2
guid: be31f9fb5f9b43ad835fdcf99969b9df
timeCreated: 1589576576

311
com.unity.perception/Editor/Randomization/ParameterConfigurationEditor.cs


using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine.Perception.Randomization.Parameters.Abstractions;
using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine.Perception.Randomization.Parameters.MonoBehaviours;
using UnityEngine.Perception.Randomization.Scenarios.Abstractions;
using UnityEngine;
using UnityEditor;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
namespace UnityEngine.Perception.Randomization.Samplers.Editor
{
[CustomEditor(typeof(ParameterConfiguration))]
public class ParameterConfigurationEditor : UnityEditor.Editor
{
ParameterConfiguration m_Config;
VisualElement m_Root;
VisualElement m_ParameterContainer;
VisualElement m_ScenarioContainer;
VisualTreeAsset m_ParameterTemplate;
const string k_TemplatesFolder = "Packages/com.unity.perception/Editor/Randomization/Uxml";
public void OnEnable()
{
m_Config = (ParameterConfiguration)target;
EditorApplication.update += UpdateStatsContainer;
}
public void OnDisable()
{
// ReSharper disable once DelegateSubtraction
EditorApplication.update -= UpdateStatsContainer;
}
public override VisualElement CreateInspectorGUI()
{
m_Root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{k_TemplatesFolder}/ParameterConfiguration.uxml").CloneTree();
m_ParameterContainer = m_Root.Query<VisualElement>("parameter-container").First();
m_ScenarioContainer = m_Root.Query<VisualElement>("configuration-container");
m_ParameterTemplate = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{k_TemplatesFolder}/ParameterTemplate.uxml");
foreach (var parameter in m_Config.parameters)
{
AddNewParameterToContainer(parameter);
}
var parameterTypeMenu = m_Root.Query<ToolbarMenu>("parameter-type-menu").First();
var parameterTypes = GetDerivedTypeOptions(typeof(ParameterBase));
foreach (var parameterType in parameterTypes)
{
parameterTypeMenu.menu.AppendAction(
parameterType.Name,
a => { AddNewParameter(parameterType); },
a => DropdownMenuAction.Status.Normal);
}
var scenarioField = m_ScenarioContainer.Query<PropertyField>("scenario-field").First();
scenarioField.RegisterCallback<ChangeEvent<Scenario>>(
evt => evt.newValue.parameterConfiguration = m_Config);
UpdateStatsContainer();
return m_Root;
}
void AddNewParameter(Type parameterType)
{
var parameterComponent = (ParameterBase)m_Config.gameObject.AddComponent(parameterType);
parameterComponent.hideFlags = HideFlags.HideInInspector;
m_Config.parameters.Add(parameterComponent);
var samplerTypes = GetDerivedTypeOptions(parameterComponent.SamplerType());
SetNewSampler(parameterComponent, samplerTypes[0]);
AddNewParameterToContainer(parameterComponent);
}
void RemoveParameter(VisualElement template)
{
var paramIndex = m_ParameterContainer.IndexOf(template);
m_ParameterContainer.RemoveAt(paramIndex);
var param = m_Config.parameters[paramIndex];
m_Config.parameters.RemoveAt(paramIndex);
DestroyImmediate(param.sampler);
DestroyImmediate(param);
}
void AddNewParameterToContainer(ParameterBase parameterComponent)
{
var templateClone = m_ParameterTemplate.CloneTree();
var so = new SerializedObject(parameterComponent);
templateClone.Bind(so);
var removeButton = templateClone.Query<Button>("remove-parameter").First();
removeButton.RegisterCallback<MouseUpEvent>(evt => RemoveParameter(templateClone));
var parameterTypeLabel = templateClone.Query<Label>("parameter-type-label").First();
parameterTypeLabel.text = parameterComponent.ParameterTypeName;
var moveUpButton = templateClone.Query<Button>("move-up-button").First();
moveUpButton.RegisterCallback<MouseUpEvent>(evt => MoveProperty(templateClone, -1));
var moveDownButton = templateClone.Query<Button>("move-down-button").First();
moveDownButton.RegisterCallback<MouseUpEvent>(evt => MoveProperty(templateClone, 1));
var hasTargetToggle = templateClone.Query<Toggle>("has-target-toggle").First();
var targetContainer = templateClone.Query<VisualElement>("target-container").First();
hasTargetToggle.RegisterCallback<ChangeEvent<bool>>(
evt => ToggleTargetContainer(targetContainer, parameterComponent.hasTarget));
ToggleTargetContainer(targetContainer, parameterComponent.hasTarget);
var targetField = templateClone.Query<PropertyField>("target-field").First();
var propertyMenu = templateClone.Query<ToolbarMenu>("property-select-menu").First();
targetField.RegisterCallback<ChangeEvent<Object>>(
evt =>
{
propertyMenu.text = "";
parameterComponent.propertyTarget = null;
AppendActionsToPropertySelectMenu(parameterComponent, propertyMenu);
});
AppendActionsToPropertySelectMenu(parameterComponent, propertyMenu);
var samplerTypeDropDown = templateClone.Query<ToolbarMenu>("sampler-type-dropdown").First();
var samplerFieldsContainer = templateClone.Query<VisualElement>("sampler-fields-container").First();
CreateSamplerPropertyFields(samplerFieldsContainer, parameterComponent.sampler);
samplerTypeDropDown.text = parameterComponent.sampler.GetType().Name;
var samplerTypes = GetDerivedTypeOptions(parameterComponent.SamplerType());
foreach (var samplerType in samplerTypes)
{
samplerTypeDropDown.menu.AppendAction(
samplerType.Name,
a =>
{
samplerTypeDropDown.text = samplerType.Name;
SetNewSampler(parameterComponent, samplerType);
CreateSamplerPropertyFields(samplerFieldsContainer, parameterComponent.sampler);
},
a => DropdownMenuAction.Status.Normal);
}
m_ParameterContainer.Add(templateClone);
}
static void ToggleTargetContainer(VisualElement targetContainer, bool toggle)
{
targetContainer.style.display = toggle
? new StyleEnum<DisplayStyle>(DisplayStyle.Flex)
: new StyleEnum<DisplayStyle>(DisplayStyle.None);
}
void SwapParameters(int first, int second)
{
var firstElement = m_ParameterContainer[first];
var secondElement = m_ParameterContainer[second];
m_ParameterContainer.RemoveAt(second);
m_ParameterContainer.RemoveAt(first);
m_ParameterContainer.Insert(first, secondElement);
m_ParameterContainer.Insert(second, firstElement);
var firstParameter = m_Config.parameters[first];
var secondParameter = m_Config.parameters[second];
m_Config.parameters[first] = secondParameter;
m_Config.parameters[second] = firstParameter;
}
void MoveProperty(VisualElement template, int direction)
{
var paramIndex = m_ParameterContainer.IndexOf(template);
if (direction == -1 && paramIndex > 0)
{
SwapParameters(paramIndex - 1, paramIndex);
}
else if (direction == 1 && paramIndex < m_Config.parameters.Count - 1)
{
SwapParameters(paramIndex, paramIndex + 1);
}
}
static List<PropertyTarget> GatherPropertyOptions(GameObject obj, Type propertyType)
{
var options = new List<PropertyTarget>();
foreach (var component in obj.GetComponents<Component>())
{
if (component == null)
continue;
var componentType = component.GetType();
var fieldInfos = componentType.GetFields();
foreach (var fieldInfo in fieldInfos)
{
if (fieldInfo.FieldType == propertyType)
options.Add(new PropertyTarget()
{
targetComponent = component,
propertyName = fieldInfo.Name,
targetKind = TargetKind.Field
});
}
var propertyInfos = componentType.GetProperties();
foreach (var propertyInfo in propertyInfos)
{
if (propertyInfo.PropertyType == propertyType)
options.Add(new PropertyTarget()
{
targetComponent = component,
propertyName = propertyInfo.Name,
targetKind = TargetKind.Property
});
}
}
return options;
}
static void AppendActionsToPropertySelectMenu(ParameterBase parameterComponent, ToolbarMenu propertyMenu)
{
propertyMenu.menu.MenuItems().Clear();
if (parameterComponent.target == null) return;
var options = GatherPropertyOptions(parameterComponent.target, parameterComponent.SampleType());
foreach (var option in options)
{
propertyMenu.menu.AppendAction(
option.propertyName,
a =>
{
parameterComponent.propertyTarget = option;
propertyMenu.text = option.propertyName;
},
a => DropdownMenuAction.Status.Normal);
}
if (parameterComponent.propertyTarget != null)
{
propertyMenu.text = parameterComponent.propertyTarget.propertyName;
}
}
void SetNewSampler(ParameterBase parameterComponent, Type samplerType)
{
if (parameterComponent.sampler != null)
DestroyImmediate(parameterComponent.sampler);
var newSampler = (SamplerBase)m_Config.gameObject.AddComponent(samplerType);
newSampler.parameter = parameterComponent;
newSampler.hideFlags = HideFlags.HideInInspector;
parameterComponent.sampler = newSampler;
}
void UpdateStatsContainer()
{
if (m_ScenarioContainer == null)
return;
var totalIterationCountLabel = m_ScenarioContainer.Query<Label>("total-iteration-count-label").First();
totalIterationCountLabel.text = $"{m_Config.TotalIterationCount}";
var totalFrameCountLabel = m_ScenarioContainer.Query<Label>("total-frame-count-label").First();
totalFrameCountLabel.text = $"{m_Config.TotalFrameCount}";
}
static void CreateSamplerPropertyFields(VisualElement samplerFieldsContainer, SamplerBase sampler)
{
samplerFieldsContainer.Clear();
var serializedSampler = new SerializedObject(sampler);
var iterator = serializedSampler.GetIterator();
if (iterator.NextVisible(true))
{
do
{
if (iterator.propertyPath == "m_Script")
continue;
var propertyField = new PropertyField(iterator.Copy());
propertyField.Bind(serializedSampler);
samplerFieldsContainer.Add(propertyField);
} while (iterator.NextVisible(false));
}
}
static Type[] GetDerivedTypeOptions(Type derivedType)
{
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
var samplerTypes = new List<Type>();
foreach (var assembly in assemblies)
{
try
{
foreach (var assemblyType in assembly.GetTypes())
{
var isNotAbstract = (assemblyType.Attributes & TypeAttributes.Abstract) == 0;
if (derivedType.IsAssignableFrom(assemblyType) && isNotAbstract)
samplerTypes.Add(assemblyType);
}
}
catch (ReflectionTypeLoadException)
{
// We can safely ignore this exception
}
}
return samplerTypes.ToArray();
}
}
}

8
com.unity.perception/Runtime/Randomization/Parameters.meta


fileFormatVersion: 2
guid: 5a083fd64edd63b489c90e6e560b7b64
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Runtime/Randomization/Parameters/Abstractions.meta


fileFormatVersion: 2
guid: 775bc238c4e9549488fadcebda4c2a9d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Runtime/Randomization/Parameters/MonoBehaviours.meta


fileFormatVersion: 2
guid: d656894e315e0504ca4c77da067815ba
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes.meta


fileFormatVersion: 2
guid: eb7af64ecbbc83746a79752eac3b38ca
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

9
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/BooleanParameter.cs


using UnityEngine.Perception.Randomization.Parameters.Abstractions;
namespace UnityEngine.Perception.Randomization.Parameters.ParameterTypes
{
public class BooleanParameter : Parameter<bool>
{
public override string ParameterTypeName => "Bool";
}
}

3
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/BooleanParameter.cs.meta


fileFormatVersion: 2
guid: 46ab2dd368b0447e9ecf5ebba212cda1
timeCreated: 1589856986

10
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/ColorParameter.cs


using UnityEngine.Perception.Randomization.Parameters.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Parameters.ParameterTypes
{
public class ColorParameter : Parameter<Color>
{
public override string ParameterTypeName => "Color";
}
}

3
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/ColorParameter.cs.meta


fileFormatVersion: 2
guid: 3898fd6ac4f242b9b312b8a86eb43538
timeCreated: 1590103038

11
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/FloatParameter.cs


using System;
using UnityEngine.Perception.Randomization.Parameters.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Parameters.ParameterTypes
{
public class FloatParameter : Parameter<float>
{
public override string ParameterTypeName => "Float";
}
}

11
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/FloatParameter.cs.meta


fileFormatVersion: 2
guid: 773d429cc1a5272458cd3e84102a5bad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/IntParameter.cs


using System;
using UnityEngine.Perception.Randomization.Parameters.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Parameters.ParameterTypes
{
public class IntParameter : Parameter<int>
{
public override string ParameterTypeName => "Int";
}
}

3
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/IntParameter.cs.meta


fileFormatVersion: 2
guid: 64f30244623b452394b1f3a91cb03adb
timeCreated: 1589677622

9
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/StringParameter.cs


using UnityEngine.Perception.Randomization.Parameters.Abstractions;
namespace UnityEngine.Perception.Randomization.Parameters.ParameterTypes
{
public class StringParameter : Parameter<string>
{
public override string ParameterTypeName => "String";
}
}

3
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/StringParameter.cs.meta


fileFormatVersion: 2
guid: 14b0a6d3298946a9a375fe4faa0211c6
timeCreated: 1589856823

10
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/Vector3Parameter.cs


using UnityEngine.Perception.Randomization.Parameters.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Parameters.ParameterTypes
{
public class Vector3Parameter : Parameter<Vector3>
{
public override string ParameterTypeName => "Vector3";
}
}

3
com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/Vector3Parameter.cs.meta


fileFormatVersion: 2
guid: 025d9d07d0fb46caa715542908189d0d
timeCreated: 1589759586

11
com.unity.perception/Runtime/Randomization/Parameters/Abstractions/Parameter.cs.meta


fileFormatVersion: 2
guid: 7706334f0f827894d80a7f98989371f0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

47
com.unity.perception/Runtime/Randomization/Parameters/Abstractions/ParameterBase.cs


using System;
using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Parameters.Abstractions
{
public abstract class ParameterBase : MonoBehaviour
{
public string parameterName = "Parameter Name";
public SamplerBase sampler;
public bool hasTarget = true;
public GameObject target;
public PropertyTarget propertyTarget;
[HideInInspector] public IterationData iterationData;
public abstract Type SamplerType();
public abstract Type SampleType();
public abstract string ParameterTypeName { get; }
protected abstract void SetupFieldOrPropertySetters();
public abstract void Apply(IterationData data);
void Awake()
{
SetupFieldOrPropertySetters();
}
}
[Serializable]
public struct IterationData
{
public int localSampleIndex;
public int globalSampleIndex;
}
[Serializable]
public class PropertyTarget
{
public Component targetComponent;
public string propertyName;
public TargetKind targetKind;
}
public enum TargetKind
{
Field, Property
}
}

3
com.unity.perception/Runtime/Randomization/Parameters/Abstractions/ParameterBase.cs.meta


fileFormatVersion: 2
guid: 0427ceeaecd0427f95450538949e40aa
timeCreated: 1589690060

102
com.unity.perception/Runtime/Randomization/Parameters/Abstractions/Parameter.cs


using System;
// using System.Reflection;
// using System.Reflection.Emit;
using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Parameters.Abstractions
{
public abstract class Parameter<T> : ParameterBase
{
Action<Component, T> m_ApplyParameterDelegate;
public override Type SamplerType()
{
return typeof(Sampler<T>);
}
public override Type SampleType()
{
return typeof(T);
}
protected override void SetupFieldOrPropertySetters()
{
// if (!hasTarget)
// return;
// var componentType = propertyTarget.targetComponent.GetType();
// switch (propertyTarget.targetKind)
// {
// case TargetKind.Field:
// var fieldInfo = componentType.GetField(propertyTarget.propertyName);
// m_ApplyParameterDelegate = CreateFieldSetter(fieldInfo, componentType);
// break;
// case TargetKind.Property:
// var propertyInfo = componentType.GetProperty(propertyTarget.propertyName);
// m_ApplyParameterDelegate = CreatePropertySetter(propertyInfo, componentType);
// break;
// }
}
public override void Apply(IterationData data)
{
iterationData = data;
UnreflectiveApply();
// if (!hasTarget)
// return;
// var value = ((Sampler<T>)sampler).NextSample();
// m_ApplyParameterDelegate(propertyTarget.targetComponent, value);
}
void UnreflectiveApply()
{
if (!hasTarget)
return;
var value = ((Sampler<T>)sampler).NextSample();
var componentType = propertyTarget.targetComponent.GetType();
switch (propertyTarget.targetKind)
{
case TargetKind.Field:
var fieldInfo = componentType.GetField(propertyTarget.propertyName);
fieldInfo.SetValue(propertyTarget.targetComponent, value);
break;
case TargetKind.Property:
var propertyInfo = componentType.GetProperty(propertyTarget.propertyName);
propertyInfo.SetValue(propertyTarget.targetComponent, value);
break;
}
}
// static Action<Component, T> CreateFieldSetter(FieldInfo field, Type componentType)
// {
// var methodName = field.ReflectedType.FullName + ".set_" + field.Name;
// var setterMethod = new DynamicMethod(
// methodName, null, new []{ typeof(Component), typeof(T) }, true);
// var gen = setterMethod.GetILGenerator();
// gen.Emit(OpCodes.Ldarg_0);
// gen.Emit(OpCodes.Castclass, componentType);
// gen.Emit(OpCodes.Ldarg_1);
// gen.Emit(OpCodes.Stfld, field);
// gen.Emit(OpCodes.Ret);
// var newDelegate = (Action<Component, T>)setterMethod.CreateDelegate(typeof(Action<Component, T>));
// return newDelegate;
// }
//
// static Action<Component, T> CreatePropertySetter(PropertyInfo property, Type componentType)
// {
// var methodName = property.ReflectedType.FullName + ".set_" + property.Name;
// var setMethod = property.GetSetMethod();
// var setterMethod = new DynamicMethod(
// methodName, null, new []{ typeof(Component), typeof(T) }, true);
// var gen = setterMethod.GetILGenerator();
// gen.Emit(OpCodes.Ldarg_0);
// gen.Emit(OpCodes.Castclass, componentType);
// gen.Emit(OpCodes.Ldarg_1);
// gen.Emit(OpCodes.Callvirt, setMethod);
// gen.Emit(OpCodes.Ret);
// var newDelegate = (Action<Component, T>)setterMethod.CreateDelegate(typeof(Action<Component, T>));
// return newDelegate;
// }
}
}

11
com.unity.perception/Runtime/Randomization/Parameters/MonoBehaviours/ParameterConfiguration.cs.meta


fileFormatVersion: 2
guid: ca07567b4377a1f41a9bcaf56d0ce8df
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

131
com.unity.perception/Runtime/Randomization/Parameters/MonoBehaviours/ParameterConfiguration.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine.Perception.Randomization.Parameters.Abstractions;
using UnityEngine.Perception.Randomization.Scenarios.Abstractions;
using UnityEngine;
using UnityEngine.Perception.Randomization.Scenarios;
namespace UnityEngine.Perception.Randomization.Parameters.MonoBehaviours
{
public class ParameterConfiguration : MonoBehaviour
{
public List<ParameterBase> parameters = new List<ParameterBase>();
public Scenario scenario;
int m_GlobalIterationIndex;
int[] m_IterationState;
bool m_HasScenario;
public int GlobalIterationIndex => m_GlobalIterationIndex;
public int TotalIterationCount
{
get
{
if (parameters.Count == 0) return 0;
var totalIterationCount = 1;
foreach (var param in parameters)
{
totalIterationCount *= param.sampler.SampleCount;
}
return totalIterationCount;
}
}
public int TotalFrameCount
{
get
{
var totalFrameCount = TotalIterationCount;
if (scenario != null)
totalFrameCount *= scenario.FrameCount;
return totalFrameCount;
}
}
public bool FinishedIterating => m_IterationState[0] >= parameters[0].sampler.SampleCount;
public void Awake()
{
if (parameters.Count == 0)
{
StopExecution();
enabled = false;
return;
}
m_IterationState = new int[parameters.Count];
if (scenario == null)
scenario = gameObject.AddComponent<EmptyScenario>();
scenario.parameterConfiguration = this;
}
void Start()
{
StartCoroutine(UpdateLoop());
}
IEnumerator UpdateLoop()
{
yield return new WaitForSeconds(1f);
while (!FinishedIterating)
{
ApplyIterationDataToParameters();
scenario.Setup();
for (var i = 0; i < scenario.FrameCount; i++)
yield return null;
scenario.Teardown();
Iterate();
}
StopExecution();
}
static void StopExecution()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
void ApplyIterationDataToParameters()
{
for (var i = 0; i < parameters.Count; i++)
{
var param = parameters[i];
var currentIteration = m_IterationState[i];
param.Apply(new IterationData {
localSampleIndex = currentIteration,
globalSampleIndex = m_GlobalIterationIndex
});
}
}
void Iterate()
{
var samplerIndex = m_IterationState.Length - 1;
m_IterationState[samplerIndex]++;
while (samplerIndex > 0 && m_IterationState[samplerIndex] == parameters[samplerIndex].sampler.SampleCount)
{
m_IterationState[samplerIndex--] = 0;
m_IterationState[samplerIndex]++;
}
m_GlobalIterationIndex++;
}
public Parameter<T> GetParameter<T>(string parameterName)
{
foreach (var parameter in parameters)
{
if (parameter.parameterName == parameterName && parameter.SampleType() == typeof(T))
{
return (Parameter<T>)parameter;
}
}
Debug.LogError($"Parameter {parameterName} not found");
return null;
}
}
}

8
com.unity.perception/Runtime/Randomization/Samplers.meta


fileFormatVersion: 2
guid: 20888c77a2d3cdf4292a74014adb9217
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Runtime/Randomization/Samplers/Abstractions.meta


fileFormatVersion: 2
guid: 5bad0a30cc86e0c4b953606938f72b12
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
com.unity.perception/Runtime/Randomization/Samplers/BooleanSamplers.meta


fileFormatVersion: 2
guid: 365541301fe743f7b42219c1f2fc0c49
timeCreated: 1589857037

16
com.unity.perception/Runtime/Randomization/Samplers/BooleanSamplers/FixedBooleanSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.BooleanSamplers
{
public class FixedBooleanSampler : Sampler<bool>
{
public bool[] samples = { false, true };
public override int SampleCount => samples.Length;
public override bool NextSample()
{
return samples[parameter.iterationData.localSampleIndex];
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/BooleanSamplers/FixedBooleanSampler.cs.meta


fileFormatVersion: 2
guid: 48a6c766fa044ceea3d140ccf2bebfe8
timeCreated: 1589857046

3
com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers.meta


fileFormatVersion: 2
guid: 6b8be950150d493b83623428f4713b0c
timeCreated: 1590103193

16
com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/FixedColorSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.ColorSamplers
{
public class FixedColorSampler : Sampler<Color>
{
public Color[] samples = { new Color() };
public override int SampleCount => samples.Length;
public override Color NextSample()
{
return samples[parameter.iterationData.localSampleIndex];
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/FixedColorSampler.cs.meta


fileFormatVersion: 2
guid: f81abb799c6f43779b0c3a1846489d0d
timeCreated: 1590103189

27
com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/GridColorSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine.Perception.Randomization.Utilities;
using Unity.Collections;
using Unity.Mathematics;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.ColorSamplers
{
public class GridColorSampler : Sampler<Color>
{
[Min(1)] public int sampleCount = 1;
public Color minSample;
public Color maxSample;
public override int SampleCount => sampleCount + 1;
public override Color NextSample()
{
var elements = new NativeArray<float4>(1, Allocator.Temp);
var colors = elements.Reinterpret<Color>();
colors[0] = minSample;
var colorSample = math.lerp(
minSample.ToFloat4(),
maxSample.ToFloat4(),
(float)parameter.iterationData.localSampleIndex / sampleCount);
return colorSample.ToColor();
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/GridColorSampler.cs.meta


fileFormatVersion: 2
guid: 5ef34b25c6f340588de080b3be27f3a0
timeCreated: 1590104186

22
com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/RandomUniformColorSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine.Perception.Randomization.Utilities;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.Vector3Samplers
{
public class RandomUniformColorSampler : RandomSampler<Color>
{
[Min(1)] public int sampleCount = 1;
public override int SampleCount => sampleCount;
public Color minSample;
public Color maxSample;
public override Color NextRandomSample(ref Unity.Mathematics.Random random)
{
var colorFloat = random.NextFloat4(
minSample.ToFloat4(),
maxSample.ToFloat4());
return colorFloat.ToColor();
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/ColorSamplers/RandomUniformColorSampler.cs.meta


fileFormatVersion: 2
guid: af02c4c13e5f4dc48d5e13e4d9b8082c
timeCreated: 1590104200

8
com.unity.perception/Runtime/Randomization/Samplers/Enums.meta


fileFormatVersion: 2
guid: ed96e6d2e53d95649a753c97f2727e31
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
com.unity.perception/Runtime/Randomization/Samplers/Enums/IterationOrigin.cs


namespace UnityEngine.Perception.Randomization.Samplers.Enums
{
public enum IterationOrigin
{
Global, Local
}
}

11
com.unity.perception/Runtime/Randomization/Samplers/Enums/IterationOrigin.cs.meta


fileFormatVersion: 2
guid: 660d13ecb12e28a458c3791eb83dc18b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers.meta


fileFormatVersion: 2
guid: 7416716d0a32fa84bb7fd321c91eb02a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

16
com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/FixedFloatSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.FloatSamplers
{
public class FixedFloatSampler : Sampler<float>
{
public float[] samples = { };
public override int SampleCount => samples.Length;
public override float NextSample()
{
return samples[parameter.iterationData.localSampleIndex];
}
}
}

11
com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/FixedFloatSampler.cs.meta


fileFormatVersion: 2
guid: dbfe67a035a54f747a91f6574438783c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/GridFloatSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using Unity.Mathematics;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.FloatSamplers
{
public class GridFloatSampler : Sampler<float>
{
[Min(1)] public int sampleCount = 1;
public override int SampleCount => sampleCount + 1;
public float minSample;
public float maxSample = 1.0f;
public override float NextSample()
{
return math.lerp(
minSample,
maxSample,
(float)parameter.iterationData.localSampleIndex / sampleCount);
}
}
}

11
com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/GridFloatSampler.cs.meta


fileFormatVersion: 2
guid: 35180060585182d41a472c80c5f79d7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

18
com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/RandomUniformFloatSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.FloatSamplers
{
public class RandomUniformFloatSampler : RandomSampler<float>
{
[Min(1)] public int sampleCount = 1;
public override int SampleCount => sampleCount;
public float minSample;
public float maxSample = 1.0f;
public override float NextRandomSample(ref Unity.Mathematics.Random random)
{
return random.NextFloat(minSample, maxSample);
}
}
}

11
com.unity.perception/Runtime/Randomization/Samplers/FloatSamplers/RandomUniformFloatSampler.cs.meta


fileFormatVersion: 2
guid: a23df5a2989ca7040b185a0a5d1d33f4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

3
com.unity.perception/Runtime/Randomization/Samplers/IntSamplers.meta


fileFormatVersion: 2
guid: cf9f8154771042c58026d3451fbc8213
timeCreated: 1589677748

16
com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/FixedIntSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.IntSamplers
{
public class FixedIntSampler : Sampler<int>
{
public int[] samples = { 0, 1 };
public override int SampleCount => samples.Length;
public override int NextSample()
{
return samples[parameter.iterationData.localSampleIndex];
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/FixedIntSampler.cs.meta


fileFormatVersion: 2
guid: 8eb04d0ede3c460daf9102bd74618922
timeCreated: 1589678351

23
com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/GridIntSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using Unity.Mathematics;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.IntSamplers
{
public class GridIntSampler : Sampler<int>
{
[Min(1)] public int sampleCount = 1;
public int minSample;
public int maxSample = 1;
public override int SampleCount => sampleCount + 1;
public override int NextSample()
{
var value = math.lerp(
minSample,
maxSample,
(float)parameter.iterationData.localSampleIndex / sampleCount);
return (int)math.round(value);
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/GridIntSampler.cs.meta


fileFormatVersion: 2
guid: a5c7abae06594ce1b81bd04cd64a1133
timeCreated: 1589772368

18
com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/RandomUniformIntSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.IntSamplers
{
public class RandomUniformIntSampler : RandomSampler<int>
{
[Min(1)] public int sampleCount = 1;
public override int SampleCount => sampleCount;
public int minSample;
public int maxSample = 1;
public override int NextRandomSample(ref Unity.Mathematics.Random random)
{
return random.NextInt(minSample, maxSample);
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/IntSamplers/RandomUniformIntSampler.cs.meta


fileFormatVersion: 2
guid: ad192cb99d1f4df8968df0bf07f554f7
timeCreated: 1589772798

3
com.unity.perception/Runtime/Randomization/Samplers/StringSamplers.meta


fileFormatVersion: 2
guid: 1eab7931bdd74382a770925f07ff425f
timeCreated: 1589856869

16
com.unity.perception/Runtime/Randomization/Samplers/StringSamplers/FixedStringSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.StringSamplers
{
public class FixedStringSampler : Sampler<string>
{
public string[] samples = { "sample" };
public override int SampleCount => samples.Length;
public override string NextSample()
{
return samples[parameter.iterationData.localSampleIndex];
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/StringSamplers/FixedStringSampler.cs.meta


fileFormatVersion: 2
guid: 54c697c2f62645b88ffc590cef3f3e5d
timeCreated: 1589856880

3
com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers.meta


fileFormatVersion: 2
guid: 633d97138431483e92166505cfce2c30
timeCreated: 1589759701

16
com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/FixedVector3Sampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.Vector3Samplers
{
public class FixedVector3Sampler : Sampler<Vector3>
{
public Vector3[] samples = { new Vector3() };
public override int SampleCount => samples.Length;
public override Vector3 NextSample()
{
return samples[parameter.iterationData.localSampleIndex];
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/FixedVector3Sampler.cs.meta


fileFormatVersion: 2
guid: fee23ab175bf4c4a99c279a76658c477
timeCreated: 1589759717

21
com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/GridVector3Sampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using Unity.Mathematics;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.Vector3Samplers
{
public class GridVector3Sampler : Sampler<Vector3>
{
[Min(1)] public int sampleCount = 1;
public Vector3 minSample;
public Vector3 maxSample;
public override int SampleCount => sampleCount + 1;
public override Vector3 NextSample()
{
return math.lerp(
minSample,
maxSample,
(float)parameter.iterationData.localSampleIndex / sampleCount);
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/GridVector3Sampler.cs.meta


fileFormatVersion: 2
guid: fcedd6d2c82b4c34abbcc2b2fb9fc85a
timeCreated: 1589759944

18
com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/RandomUniformVector3Sampler.cs


using UnityEngine.Perception.Randomization.Samplers.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.Vector3Samplers
{
public class RandomUniformVector3Sampler : RandomSampler<Vector3>
{
[Min(1)] public int sampleCount = 1;
public override int SampleCount => sampleCount;
public Vector3 minSample;
public Vector3 maxSample;
public override Vector3 NextRandomSample(ref Unity.Mathematics.Random random)
{
return random.NextFloat3(minSample, maxSample);
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/Vector3Samplers/RandomUniformVector3Sampler.cs.meta


fileFormatVersion: 2
guid: 06adb42fc0a748f1b349226c1f78a553
timeCreated: 1589760088

42
com.unity.perception/Runtime/Randomization/Samplers/Abstractions/RandomSampler.cs


using UnityEngine.Perception.Randomization.Samplers.Enums;
using UnityEngine.Perception.Randomization.Utilities;
using Unity.Collections;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.Abstractions
{
public abstract class RandomSampler<T> : Sampler<T> where T : struct
{
public IterationOrigin iterationOrigin;
public uint baseRandomSeed = RandomUtility.defaultBaseSeed;
protected uint GetRandomSeed()
{
var data = parameter.iterationData;
var iteration = iterationOrigin == IterationOrigin.Local
? data.localSampleIndex
: data.globalSampleIndex;
return RandomUtility.SeedFromIndex((uint)iteration, baseRandomSeed);
}
public override T NextSample()
{
var random = new Unity.Mathematics.Random(GetRandomSeed());
return NextRandomSample(ref random);
}
public abstract T NextRandomSample(ref Unity.Mathematics.Random random);
public NativeArray<T> RandomSamples(int sampleCount, Allocator allocator)
{
var random = new Unity.Mathematics.Random(GetRandomSeed());
var samples = new NativeArray<T>(sampleCount, allocator, NativeArrayOptions.UninitializedMemory);
for (var i = 0; i < sampleCount; i++)
{
samples[i] = NextRandomSample(ref random);
}
return samples;
}
}
}

3
com.unity.perception/Runtime/Randomization/Samplers/Abstractions/RandomSampler.cs.meta


fileFormatVersion: 2
guid: 57fb56c8be9f44d38479470caa648ab6
timeCreated: 1589918601

15
com.unity.perception/Runtime/Randomization/Samplers/Abstractions/Sampler.cs


using System;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.Abstractions
{
public abstract class Sampler<T> : SamplerBase
{
public abstract T NextSample();
public override string GetSampleString()
{
return $"{NextSample()}";
}
}
}

11
com.unity.perception/Runtime/Randomization/Samplers/Abstractions/Sampler.cs.meta


fileFormatVersion: 2
guid: d468a141dd9229f4ebd37ad6db823ba5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

3
com.unity.perception/Runtime/Randomization/Samplers/Abstractions/SamplerBase.cs.meta


fileFormatVersion: 2
guid: bcc9021677da40bbb1fb797cd5387cba
timeCreated: 1589688704

13
com.unity.perception/Runtime/Randomization/Samplers/Abstractions/SamplerBase.cs


using UnityEngine.Perception.Randomization.Parameters.Abstractions;
using UnityEngine;
namespace UnityEngine.Perception.Randomization.Samplers.Abstractions
{
public abstract class SamplerBase : MonoBehaviour
{
[HideInInspector] public ParameterBase parameter;
public abstract int SampleCount { get; }
public abstract string GetSampleString();
}
}

8
com.unity.perception/Runtime/Randomization/Scenarios.meta


fileFormatVersion: 2
guid: 1506ec4051d1c1349ba6876e3fdf1a92
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存