浏览代码
Merge pull request #79 from Unity-Technologies/randomizers
Merge pull request #79 from Unity-Technologies/randomizers
Added Randomizers and RandomizerTags/main
GitHub
4 年前
当前提交
f4522d55
共有 237 个文件被更改,包括 2053 次插入 和 550 次删除
-
4com.unity.perception/CHANGELOG.md
-
74com.unity.perception/Documentation~/Randomization/Index.md
-
50com.unity.perception/Documentation~/Randomization/Scenarios.md
-
66com.unity.perception/Editor/Randomization/StaticData.cs
-
220com.unity.perception/Editor/Randomization/Uss/Styles.uss
-
4com.unity.perception/Editor/Randomization/Uss/Styles.uss.meta
-
17com.unity.perception/Editor/Randomization/Uxml/ScenarioBaseElement.uxml
-
7com.unity.perception/Editor/Unity.Perception.Editor.asmdef
-
5com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/OutlineMaterial.mat
-
76com.unity.perception/Runtime/Randomization/Parameters/CategoricalParameter.cs
-
4com.unity.perception/Runtime/Randomization/Parameters/CategoricalParameterBase.cs
-
15com.unity.perception/Runtime/Randomization/Parameters/NumericParameter.cs
-
74com.unity.perception/Runtime/Randomization/Parameters/Parameter.cs
-
2com.unity.perception/Runtime/Randomization/Samplers/FloatRange.cs
-
16com.unity.perception/Runtime/Randomization/Samplers/SamplerTypes/ConstantSampler.cs
-
21com.unity.perception/Runtime/Randomization/Samplers/SamplerTypes/NormalSampler.cs
-
21com.unity.perception/Runtime/Randomization/Samplers/SamplerTypes/UniformSampler.cs
-
2com.unity.perception/Runtime/Randomization/Samplers/SamplerUtility.cs
-
27com.unity.perception/Runtime/Randomization/Scenarios/FixedLengthScenario.cs
-
26com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs
-
289com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
-
12com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs.meta
-
10com.unity.perception/Tests/Runtime/Randomization/ParameterTests/CategoricalParameterTests.cs
-
63com.unity.perception/Tests/Runtime/Randomization/ScenarioTests.cs
-
1com.unity.perception/package.json
-
2com.unity.perception/Editor/Randomization/Uxml/Sampler/FloatRangeElement.uxml
-
2com.unity.perception/Editor/Randomization/VisualElements/Randomizer/DragToReorderManipulator.cs.meta
-
2com.unity.perception/Editor/Randomization/VisualElements/Parameter/CategoricalOptionElement.cs
-
3com.unity.perception/Editor/Randomization/VisualElements/Sampler/FloatRangeElement.cs
-
35com.unity.perception/Editor/Randomization/VisualElements/Randomizer/DragToReorderManipulator.cs
-
5com.unity.perception/Editor/Randomization/VisualElements/Sampler/SamplerElement.cs
-
22com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/NumericParameters/BooleanParameter.cs
-
8com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/NumericParameters/FloatParameter.cs
-
8com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/NumericParameters/IntegerParameter.cs
-
12com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/NumericParameters/Vector2Parameter.cs
-
13com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/NumericParameters/Vector3Parameter.cs
-
14com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/NumericParameters/Vector4Parameter.cs
-
3com.unity.perception.meta
-
29com.unity.perception/Documentation~/Randomization/RandomizerTags.md
-
42com.unity.perception/Documentation~/Randomization/Randomizers.md
-
8com.unity.perception/Editor/Randomization/Editors.meta
-
5com.unity.perception/Editor/Randomization/Icons/ChevronLeft.png
-
144com.unity.perception/Editor/Randomization/Icons/ChevronLeft.png.meta
-
6com.unity.perception/Editor/Randomization/Icons/ChevronRight.png
-
144com.unity.perception/Editor/Randomization/Icons/ChevronRight.png.meta
-
8com.unity.perception/Editor/Randomization/PropertyDrawers.meta
-
3com.unity.perception/Editor/Randomization/Uxml/Parameter.meta
-
3com.unity.perception/Editor/Randomization/Uxml/Randomizer.meta
-
14com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml
-
10com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml.meta
-
3com.unity.perception/Editor/Randomization/Uxml/Sampler.meta
-
8com.unity.perception/Editor/Randomization/VisualElements.meta
-
3com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/CategorialParameters.meta
-
3com.unity.perception/Runtime/Randomization/Parameters/ParameterTypes/NumericParameters.meta
-
8com.unity.perception/Runtime/Randomization/Randomizers.meta
-
65com.unity.perception/Runtime/Randomization/Scenarios/USimScenario.cs
-
3com.unity.perception/Runtime/Randomization/Scenarios/USimScenario.cs.meta
-
8com.unity.perception/Tests/Runtime/Randomization/RandomizerTests.meta
-
88com.unity.perception/Editor/Randomization/Editors/ScenarioBaseEditor.cs
-
8com.unity.perception/Editor/Randomization/Editors/ScenarioBaseEditor.cs.meta
-
11com.unity.perception/Editor/Randomization/Editors/RunInUSimWindow.cs.meta
-
247com.unity.perception/Editor/Randomization/Editors/RunInUSimWindow.cs
-
25com.unity.perception/Editor/Randomization/PropertyDrawers/ColorHsvaDrawer.cs
-
8com.unity.perception/Editor/Randomization/PropertyDrawers/ColorHsvaDrawer.cs.meta
-
26com.unity.perception/Editor/Randomization/PropertyDrawers/ParameterDrawer.cs
-
8com.unity.perception/Editor/Randomization/PropertyDrawers/ParameterDrawer.cs.meta
-
8com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalOptionElement.uxml
-
12com.unity.perception/Editor/Randomization/Uxml/Parameter/CategoricalParameterTemplate.uxml
-
10com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterDrawer.uxml
-
8com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterDrawer.uxml.meta
-
6com.unity.perception/Editor/Randomization/Uxml/Parameter/ParameterElement.uxml
-
3com.unity.perception/Editor/Randomization/Uxml/Randomizer/AddRandomizerMenu.uxml.meta
-
3com.unity.perception/Editor/Randomization/Uxml/Randomizer/MenuDirectoryElement.uxml.meta
-
3com.unity.perception/Editor/Randomization/Uxml/Randomizer/RandomizerElement.uxml.meta
-
3com.unity.perception/Editor/Randomization/Uxml/Randomizer/RandomizerList.uxml.meta
-
13com.unity.perception/Editor/Randomization/Uxml/Randomizer/AddRandomizerMenu.uxml
-
6com.unity.perception/Editor/Randomization/Uxml/Randomizer/MenuDirectoryElement.uxml
-
16com.unity.perception/Editor/Randomization/Uxml/Randomizer/RandomizerElement.uxml
-
8com.unity.perception/Editor/Randomization/Uxml/Randomizer/RandomizerList.uxml
-
10com.unity.perception/Editor/Randomization/Uxml/Sampler/SamplerElement.uxml
-
3com.unity.perception/Editor/Randomization/VisualElements/Parameter.meta
-
8com.unity.perception/Editor/Randomization/VisualElements/Parameter/CategoricalOptionElement.cs.meta
-
39com.unity.perception/Editor/Randomization/VisualElements/Parameter/ColorHsvaField.cs
-
8com.unity.perception/Editor/Randomization/VisualElements/Parameter/ColorHsvaField.cs.meta
-
48com.unity.perception/Editor/Randomization/VisualElements/Parameter/DrawerParameterElement.cs
-
8com.unity.perception/Editor/Randomization/VisualElements/Parameter/DrawerParameterElement.cs.meta
-
196com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs
-
8com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs.meta
-
3com.unity.perception/Editor/Randomization/VisualElements/Randomizer.meta
|
|||
# Scenarios |
|||
|
|||
Scenarios have three responsibilities: |
|||
1. Controlling the execution flow of your simulation |
|||
2. Customizing the application of random parameters in your project |
|||
3. Defining constants that can be configured externally from a built Unity player |
|||
1. Controlling the execution flow of your simulation |
|||
2. Defining a list of randomizers |
|||
3. Defining constants that can be configured externally from a built Unity player |
|||
|
|||
By default, the perception package includes one ready-made scenario, the `FixedLengthScenario` class. This scenario runs each iteration for a fixed number of frames and is compatible with the Run in USim window for cloud simulation execution. |
|||
|
|||
## Scenario Cloud Execution (USim) |
|||
|
|||
Users can utilize Unity's Unity Simulation (USim) service to execute a scenario in the cloud through the perception package's Run in USim window. To open this window from the Unity editor using the top menu bar, navigate to `Window -> Run in USim`. |
|||
|
|||
From the newly opened editor window, customize the following settings to configure a new USim run: |
|||
1. **Run Name** - the name of the USim run (example: TestRun0) |
|||
2. **Total Iterations** - The number of scenario iterations to complete during the run |
|||
3. **Instance Count** - The number of USim worker instances to distribute execution between |
|||
4. **Main Scene** - The Unity scene to execute |
|||
5. **Scenario** - The scenario to execute |
|||
6. **USim Worker Config** - the type of USim worker instance to execute the scenario with. Determines per instance specifications such as the number of CPU cores, amount of memory, and presence of a GPU for accelerated execution. |
|||
By default, the perception package includes one ready-made scenario, the `FixedFrameLengthScenario` class. This scenario is useful for when all created parameters have target GameObjects configured directly in the `ParameterConfiguration` and the scenario execution requires little modification. |
|||
NOTE: To execute a scenario using the Run in USim window, the scenario class must implement the USimScenario class. |
|||
More commonly, users will find the need to create their own Scenario class. Below is an overview of the more common scenario properties and methods a user can override: |
|||
|
|||
## Custom Scenarios |
|||
|
|||
For use cases where the scenario should run for an arbitrary number of frames, implementing a custom scenario may be necessary. Below are the two most common scenario properties a user might want to override to implement custom scenario iteration conditions: |
|||
3. **Initialize** - actions to complete before the scenario has begun iterating |
|||
4. **Setup** - actions to complete at the beginning of each iteration |
|||
5. **Teardown** - actions to complete at the end of each iteration |
|||
6. **OnComplete** - actions to complete after the scenario as completed |
|||
|
|||
Scenarios define constants from which to expose global simulation behaviors like a starting iteration value or a total iteration count. Users can serialize these scenario constants to JSON, modify them in an external program, and finally reimport the JSON constants at runtime to configure their simulation even after their project has been built. Below is an example of the constants used in the `FixedLengthScenario` class: |
|||
Scenarios define constants from which to expose global simulation behaviors like a starting iteration value or a total iteration count. Users can serialize these scenario constants to JSON, modify them in an external program, and finally reimport the JSON constants at runtime to configure their simulation even after their project has been built. Below is an example of the constants class used in the `FixedLengthScenario` class: |
|||
public class Constants |
|||
public class Constants : USimConstants |
|||
public int iterationFrameLength = 1; |
|||
public int startingIteration; |
|||
public int totalIterations = 1000; |
|||
public int framesPerIteration = 1; |
|||
A few key things to note here: |
|||
1. Make sure to include the [Serializable] attribute on a constant class. This will ensure that the constants can be manipulated from the Unity inspector. |
|||
2. By default, UnityEngine.Object class references cannot be serialized to JSON in a meaningful way. This includes Monobehaviors and SerializedObjects. For more information on what can and can't be serialized, take a look at the [Unity JsonUtility manual](https://docs.unity3d.com/ScriptReference/JsonUtility.html). |
|||
3. A scenario class's Serialize() and Deserialized() methods can be overriden to implement custom serialization strategies. |
|||
|
|||
There are a few key things to note here: |
|||
1. The constants class will need to inherit from USimConstants to be compatible with the Run in USim window. Deriving from USimConstants will add a few key properties to the constants class that are needed to coordinate a USim run. |
|||
2. Make sure to include the [Serializable] attribute on a constant class. This will ensure that the constants can be manipulated from the Unity inspector. |
|||
3. By default, UnityEngine.Object class references cannot be serialized to JSON in a meaningful way. This includes Monobehaviors and SerializedObjects. For more information on what can and can't be serialized, take a look at the [Unity JsonUtility manual](https://docs.unity3d.com/ScriptReference/JsonUtility.html). |
|||
4. A scenario class's Serialize() and Deserialized() methods can be overriden to implement custom serialization strategies. |
|
|||
fileFormatVersion: 2 |
|||
guid: 5e1a10e7ee7a46898d0138a9d08615ee |
|||
timeCreated: 1589577216 |
|||
guid: a3321de444a246f59e8a0445d5d2bf5d |
|||
timeCreated: 1601665266 |
|
|||
fileFormatVersion: 2 |
|||
fileFormatVersion: 2 |
|||
timeCreated: 1589772146 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2c0b9128211c487091d21926e24c3303 |
|||
timeCreated: 1600211324 |
|
|||
# Randomizer Tags |
|||
|
|||
RandomizerTags are the primary mechanism by which randomizers query for a certain subset of GameObjects to randomize within a simulation. |
|||
|
|||
More specifically, RandomizerTags are components that can be added to GameObjects to register them with the active scenario's TagManager. This TagManager is aware of all objects with tags in the scene and can be queried to find all GameObjects that contain a specific tag. Below is a simple example of a ColorRandomizer querying for all GameObjects with a ColorRandomizerTag that it will apply a random material base color to: |
|||
|
|||
``` |
|||
[Serializable] |
|||
[AddRandomizerMenu("Perception/Color Randomizer")] |
|||
public class ColorRandomizer : Randomizer |
|||
{ |
|||
static readonly int k_BaseColor = Shader.PropertyToID("_BaseColor"); |
|||
|
|||
public ColorHsvaParameter colorParameter; |
|||
|
|||
protected override void OnIterationStart() |
|||
{ |
|||
var taggedObjects = tagManager.Query<ColorRandomizerTag>(); |
|||
foreach (var taggedObject in taggedObjects) |
|||
{ |
|||
var renderer = taggedObject.GetComponent<MeshRenderer>(); |
|||
renderer.material.SetColor(k_BaseColor, colorParameter.Sample()); |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
RandomizerTags can also be used to customize how randomizers apply their randomizations to a particular GameObject. Visit [part two of the randomization tutorial]() to explore an in depth example of implementing a LightRandomizer that does exactly this. |
|||
|
|
|||
# Randomizers |
|||
|
|||
Randomizers encapsulate specific randomization activities to perform during the execution of a randomized simulation. For example, randomizers exist for spawning objects, repositioning lights, varying the color of objects, etc. Randomizers expose random parameters to their inspector interface to further customize these variations. Users can add a set of randomizers to a scenario in order to define an ordered list randomization activities to perform during the lifecycle of a simulation. |
|||
|
|||
To define an entirely new randomizer, derive the Randomizer class and implement one or more of the methods listed in the section below to randomize GameObjects during the runtime of a simulation. |
|||
|
|||
|
|||
## Randomizer Hooks |
|||
|
|||
1. OnCreate() - called when the Randomizer is added or loaded to a scenario |
|||
2. OnIterationStart() - called at the start of a new scenario iteration |
|||
3. OnIterationEnd() - called the after a scenario iteration has completed |
|||
4. OnScenarioComplete() - called the after the entire scenario has completed |
|||
5. OnStartRunning() - called on the first frame a Randomizer is enabled |
|||
6. OnStopRunning() - called on the first frame a disabled Randomizer is updated |
|||
7. OnUpdate() - executed every frame for enabled Randomizers |
|||
|
|||
|
|||
## Randomizer Coding Example |
|||
|
|||
Below is the code for the sample rotation randomizer included with the perception package: |
|||
|
|||
``` |
|||
[Serializable] |
|||
[AddRandomizerMenu("Perception/Rotation Randomizer")] |
|||
public class RotationRandomizer : Randomizer |
|||
{ |
|||
public Vector3Parameter rotation = new Vector3Parameter(); |
|||
|
|||
protected override void OnIterationStart() |
|||
{ |
|||
var taggedObjects = tagManager.Query<RotationRandomizerTag>(); |
|||
foreach (var taggedObject in taggedObjects) |
|||
taggedObject.transform.rotation = Quaternion.Euler(rotation.Sample()); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
There are a few key things to note from this example: |
|||
1. Make sure to add the [Serializable] tag to all randomizer implementations to ensure that the randomizer can be customized and saved within the Unity Editor. |
|||
2. The [AddRandomizerMenu] attribute customizes the "Add Randomizer" sub menu path in the scenario inspector for a particular randomizer. In this example, the RotationRandomizer can be added to a scenario by opening the add randomizer menu and clicking `Perception -> Rotation Randomizer`. |
|||
3. The line `var taggedObjects = tagManager.Query<RotationRandomizerTag>();` uses RandomizerTags in combination with the current Scenario's tagManager to query for all objects with RotationRandomizerTags to obtain the subset of GameObjects within the simulation that need to have their rotations randomzied. To learn more about how RandomizerTags work, visit the [RandomizerTags doc](RandomizerTags.md). |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: 85401640505a48f9a8fe55045f5f28d8 |
|||
timeCreated: 1600754567 |
|||
======= |
|||
guid: 0b17046409af4c22bf74eec2a5965984 |
|||
timeCreated: 1598135707 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
fileFormatVersion: 2 |
|||
guid: 8ccf58823c99c574f9cfb36e2e051078 |
|||
TextureImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 11 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
streamingMipmaps: 0 |
|||
streamingMipmapsPriority: 0 |
|||
vTOnly: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: 2 |
|||
mipBias: -100 |
|||
wrapU: 0 |
|||
wrapV: 0 |
|||
wrapW: 0 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
flipbookRows: 1 |
|||
flipbookColumns: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
ignorePngGamma: 0 |
|||
applyGammaDecoding: 0 |
|||
platformSettings: |
|||
- serializedVersion: 3 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: Standalone |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: iPhone |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: Android |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: Windows Store Apps |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
internalID: 0 |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
secondaryTextures: [] |
|||
spritePackingTag: |
|||
pSDRemoveMatte: 0 |
|||
pSDShowRemoveMatteOption: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 799cb8d9484d2ea4a9d4ddd15bda85aa |
|||
TextureImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 11 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
streamingMipmaps: 0 |
|||
streamingMipmapsPriority: 0 |
|||
vTOnly: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: 2 |
|||
mipBias: -100 |
|||
wrapU: 0 |
|||
wrapV: 0 |
|||
wrapW: 0 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
flipbookRows: 1 |
|||
flipbookColumns: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
ignorePngGamma: 0 |
|||
applyGammaDecoding: 0 |
|||
platformSettings: |
|||
- serializedVersion: 3 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: Standalone |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: iPhone |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: Android |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: Windows Store Apps |
|||
maxTextureSize: 8192 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
internalID: 0 |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
secondaryTextures: [] |
|||
spritePackingTag: |
|||
pSDRemoveMatte: 0 |
|||
pSDShowRemoveMatteOption: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: 47a26876f92a4b19adb3b7b525efa830 |
|||
timeCreated: 1600754588 |
|||
======= |
|||
guid: d3107e026b2943c1868c9b3f8c6480d3 |
|||
timeCreated: 1598135730 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
fileFormatVersion: 2 |
|||
guid: 9dff455d50ac4549bac301eb5926c83c |
|||
timeCreated: 1601668963 |
|
|||
fileFormatVersion: 2 |
|||
guid: 006b3ab9c14b41f581f235810765469c |
|||
timeCreated: 1600991712 |
|
|||
<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> |
|
|||
fileFormatVersion: 2 |
|||
guid: 678c5d944639402c9c4d50de04c77561 |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
|
|||
fileFormatVersion: 2 |
|||
guid: cdf29c5fa139470d961ca4605d792f0a |
|||
timeCreated: 1601668985 |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: 64930d74a0b54875ab472b72066417bc |
|||
timeCreated: 1600754567 |
|||
======= |
|||
guid: 7f8f95a1bb144a96b9310164f5560387 |
|||
timeCreated: 1598135666 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
fileFormatVersion: 2 |
|||
guid: e09548ac8cf147b6b8ce910112ae97c4 |
|||
timeCreated: 1600890464 |
|
|||
fileFormatVersion: 2 |
|||
guid: db7c97a0f5014b73a7af47aa6f6a276a |
|||
timeCreated: 1600890440 |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: 80645bae9cd440ca81c7a1e03572e7da |
|||
timeCreated: 1600754588 |
|||
======= |
|||
guid: ae6aad06c0e14f67aa7a9ad9004a1828 |
|||
timeCreated: 1600274594 |
|||
>>>>>>> c653d18... Implemented randomizer class. Ran into SerializeReference issue 1193322. |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.Experimental.Perception.Randomization.Scenarios |
|||
{ |
|||
/// <summary>
|
|||
/// Defines a scenario that is compatible with the Run in USim window
|
|||
/// </summary>
|
|||
/// <typeparam name="T">The type of constants to serialize</typeparam>
|
|||
public abstract class USimScenario<T> : Scenario<T> where T : USimConstants, new() |
|||
{ |
|||
/// <summary>
|
|||
/// Returns whether the entire scenario has completed
|
|||
/// </summary>
|
|||
public sealed override bool isScenarioComplete => currentIteration >= constants.totalIterations; |
|||
|
|||
/// <summary>
|
|||
/// OnAwake is executed directly after this scenario has been registered and initialized
|
|||
/// </summary>
|
|||
protected sealed override void OnAwake() |
|||
{ |
|||
currentIteration = constants.instanceIndex; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Progresses the current scenario iteration
|
|||
/// </summary>
|
|||
protected sealed override void IncrementIteration() |
|||
{ |
|||
currentIteration += constants.instanceCount; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Deserializes this scenario's constants from the USim AppParams Json file
|
|||
/// </summary>
|
|||
public sealed override void Deserialize() |
|||
{ |
|||
if (string.IsNullOrEmpty(Unity.Simulation.Configuration.Instance.SimulationConfig.app_param_uri)) |
|||
base.Deserialize(); |
|||
else |
|||
constants = Unity.Simulation.Configuration.Instance.GetAppParams<T>(); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// A class encapsulating the scenario constants fields required for USim cloud execution
|
|||
/// </summary>
|
|||
[Serializable] |
|||
public class USimConstants |
|||
{ |
|||
/// <summary>
|
|||
/// The total number of iterations to run a scenario for
|
|||
/// </summary>
|
|||
public int totalIterations = 100; |
|||
|
|||
/// <summary>
|
|||
/// The number of USim instances assigned to executed this scenario
|
|||
/// </summary>
|
|||
public int instanceCount = 1; |
|||
|
|||
/// <summary>
|
|||
/// The USim instance index of the currently executing worker
|
|||
/// </summary>
|
|||
public int instanceIndex; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ee12a68b9b7b40aa9f60c97d6078a7cf |
|||
timeCreated: 1601067341 |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: 6693ffffff2148b0a248e1d8c5ddc805 |
|||
timeCreated: 1600754588 |
|||
======= |
|||
guid: f9e02c502b7845229d26d377a0d871f1 |
|||
timeCreated: 1600744200 |
|||
>>>>>>> cb407fb... added randomizer tests |
|
|||
using UnityEditor; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.Experimental.Perception.Randomization.Scenarios; |
|||
using UnityEngine.Experimental.Perception.Randomization.VisualElements; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Experimental.Perception.Randomization.Editor |
|||
{ |
|||
[CustomEditor(typeof(ScenarioBase), true)] |
|||
class ScenarioBaseEditor : UnityEditor.Editor |
|||
{ |
|||
ScenarioBase m_Scenario; |
|||
SerializedObject m_SerializedObject; |
|||
VisualElement m_Root; |
|||
VisualElement m_InspectorPropertiesContainer; |
|||
VisualElement m_ConstantsContainer; |
|||
VisualElement m_RandomizerListPlaceholder; |
|||
SerializedProperty m_ConstantsProperty; |
|||
|
|||
public override VisualElement CreateInspectorGUI() |
|||
{ |
|||
m_Scenario = (ScenarioBase)target; |
|||
m_SerializedObject = new SerializedObject(m_Scenario); |
|||
m_Root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/ScenarioBaseElement.uxml").CloneTree(); |
|||
|
|||
var serializeConstantsButton = m_Root.Q<Button>("serialize-constants"); |
|||
serializeConstantsButton.clicked += () => m_Scenario.Serialize(); |
|||
|
|||
var deserializeConstantsButton = m_Root.Q<Button>("deserialize-constants"); |
|||
deserializeConstantsButton.clicked += () => m_Scenario.Deserialize(); |
|||
|
|||
m_RandomizerListPlaceholder = m_Root.Q<VisualElement>("randomizer-list-placeholder"); |
|||
|
|||
CreatePropertyFields(); |
|||
CheckIfConstantsExist(); |
|||
|
|||
return m_Root; |
|||
} |
|||
|
|||
void CreatePropertyFields() |
|||
{ |
|||
m_InspectorPropertiesContainer = m_Root.Q<VisualElement>("inspector-properties"); |
|||
m_InspectorPropertiesContainer.Clear(); |
|||
|
|||
var iterator = m_SerializedObject.GetIterator(); |
|||
var foundProperties = false; |
|||
if (iterator.NextVisible(true)) |
|||
{ |
|||
do |
|||
{ |
|||
switch (iterator.name) |
|||
{ |
|||
case "m_Script": |
|||
break; |
|||
case "constants": |
|||
m_ConstantsProperty = iterator.Copy(); |
|||
break; |
|||
case "m_Randomizers": |
|||
m_RandomizerListPlaceholder.Add(new RandomizerList(iterator.Copy())); |
|||
break; |
|||
default: |
|||
{ |
|||
foundProperties = true; |
|||
var propertyField = new PropertyField(iterator.Copy()); |
|||
propertyField.Bind(m_SerializedObject); |
|||
m_InspectorPropertiesContainer.Add(propertyField); |
|||
break; |
|||
} |
|||
} |
|||
} while (iterator.NextVisible(false)); |
|||
} |
|||
|
|||
if (!foundProperties) |
|||
m_InspectorPropertiesContainer.style.display = new StyleEnum<DisplayStyle>(DisplayStyle.None); |
|||
} |
|||
|
|||
void CheckIfConstantsExist() |
|||
{ |
|||
m_ConstantsContainer = m_Root.Q<VisualElement>("constants-container"); |
|||
if (m_ConstantsProperty == null) |
|||
{ |
|||
m_InspectorPropertiesContainer.style.marginBottom = 0; |
|||
m_ConstantsContainer.style.display = new StyleEnum<DisplayStyle>(DisplayStyle.None); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: 57a29c3831024d55aca1a6267dabb56c |
|||
timeCreated: 1600754583 |
|||
======= |
|||
guid: face5e97e23d402cbf6fafadb39fa0c3 |
|||
timeCreated: 1596213301 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
fileFormatVersion: 2 |
|||
guid: 2744f10e153915b46a2f6a274914753d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Unity.Simulation.Client; |
|||
using UnityEditor; |
|||
using UnityEditor.Build.Reporting; |
|||
using UnityEditor.SceneManagement; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.Experimental.Perception.Randomization.Editor; |
|||
using UnityEngine.Experimental.Perception.Randomization.Scenarios; |
|||
using UnityEngine.SceneManagement; |
|||
using UnityEngine.UIElements; |
|||
using ZipUtility; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
class RunInUSimWindow : EditorWindow |
|||
{ |
|||
string m_BuildDirectory; |
|||
|
|||
string m_BuildZipPath; |
|||
SysParamDefinition m_SysParam; |
|||
|
|||
TextField m_RunNameField; |
|||
IntegerField m_TotalIterationsField; |
|||
IntegerField m_InstanceCountField; |
|||
ObjectField m_MainSceneField; |
|||
ObjectField m_ScenarioField; |
|||
Button m_RunButton; |
|||
|
|||
[MenuItem("Window/Run in USim")] |
|||
static void ShowWindow() |
|||
{ |
|||
var window = GetWindow<RunInUSimWindow>(); |
|||
window.titleContent = new GUIContent("Run In Unity Simulation"); |
|||
window.minSize = new Vector2(250, 50); |
|||
window.Show(); |
|||
} |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_BuildDirectory = Application.dataPath + "/../Build"; |
|||
Project.Activate(); |
|||
Project.clientReadyStateChanged += CreateEstablishingConnectionUI; |
|||
CreateEstablishingConnectionUI(Project.projectIdState); |
|||
} |
|||
|
|||
void OnFocus() |
|||
{ |
|||
Application.runInBackground = true; |
|||
} |
|||
|
|||
void OnLostFocus() |
|||
{ |
|||
Application.runInBackground = false; |
|||
} |
|||
|
|||
void CreateEstablishingConnectionUI(Project.State state) |
|||
{ |
|||
rootVisualElement.Clear(); |
|||
if (Project.projectIdState == Project.State.Pending) |
|||
{ |
|||
var waitingText = new TextElement(); |
|||
waitingText.text = "Waiting for connection to Unity Cloud..."; |
|||
rootVisualElement.Add(waitingText); |
|||
} |
|||
else if (Project.projectIdState == Project.State.Invalid) |
|||
{ |
|||
var waitingText = new TextElement(); |
|||
waitingText.text = "The current project must be associated with a valid Unity Cloud project " + |
|||
"to run in Unity Simulation"; |
|||
rootVisualElement.Add(waitingText); |
|||
} |
|||
else |
|||
{ |
|||
CreateRunInUSimUI(); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Enables a visual element to remember values between editor sessions
|
|||
/// </summary>
|
|||
/// <param name="element">The visual element to enable view data for</param>
|
|||
static void SetViewDataKey(VisualElement element) |
|||
{ |
|||
element.viewDataKey = $"RunInUSim_{element.name}"; |
|||
} |
|||
|
|||
void CreateRunInUSimUI() |
|||
{ |
|||
var root = rootVisualElement; |
|||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/RunInUSimWindow.uxml").CloneTree(root); |
|||
|
|||
m_RunNameField = root.Q<TextField>("run-name"); |
|||
SetViewDataKey(m_RunNameField); |
|||
|
|||
m_TotalIterationsField = root.Q<IntegerField>("total-iterations"); |
|||
SetViewDataKey(m_TotalIterationsField); |
|||
|
|||
m_InstanceCountField = root.Q<IntegerField>("instance-count"); |
|||
SetViewDataKey(m_InstanceCountField); |
|||
|
|||
m_MainSceneField = root.Q<ObjectField>("main-scene"); |
|||
m_MainSceneField.objectType = typeof(SceneAsset); |
|||
if (SceneManager.sceneCount > 0) |
|||
{ |
|||
var path = SceneManager.GetSceneAt(0).path; |
|||
var asset = AssetDatabase.LoadAssetAtPath<SceneAsset>(path); |
|||
m_MainSceneField.value = asset; |
|||
} |
|||
|
|||
m_ScenarioField = root.Q<ObjectField>("scenario"); |
|||
m_ScenarioField.objectType = typeof(ScenarioBase); |
|||
m_ScenarioField.value = FindObjectOfType<ScenarioBase>(); |
|||
|
|||
var sysParamDefinitions = API.GetSysParams(); |
|||
var sysParamMenu = root.Q<ToolbarMenu>("sys-param"); |
|||
foreach (var definition in sysParamDefinitions) |
|||
{ |
|||
sysParamMenu.menu.AppendAction( |
|||
definition.description, |
|||
action => |
|||
{ |
|||
m_SysParam = definition; |
|||
sysParamMenu.text = definition.description; |
|||
}); |
|||
} |
|||
sysParamMenu.text = sysParamDefinitions[0].description; |
|||
m_SysParam = sysParamDefinitions[0]; |
|||
|
|||
m_RunButton = root.Q<Button>("run-button"); |
|||
m_RunButton.clicked += RunInUSim; |
|||
} |
|||
|
|||
async void RunInUSim() |
|||
{ |
|||
ValidateSettings(); |
|||
CreateLinuxBuildAndZip(); |
|||
await StartUSimRun(); |
|||
} |
|||
|
|||
void ValidateSettings() |
|||
{ |
|||
if (string.IsNullOrEmpty(m_RunNameField.value)) |
|||
throw new MissingFieldException("Empty run name"); |
|||
if (m_MainSceneField.value == null) |
|||
throw new MissingFieldException("Main scene unselected"); |
|||
if (m_ScenarioField.value == null) |
|||
throw new MissingFieldException("Scenario unselected"); |
|||
var scenario = (ScenarioBase)m_ScenarioField.value; |
|||
if (!StaticData.IsSubclassOfRawGeneric(typeof(USimScenario<>), scenario.GetType())) |
|||
throw new NotSupportedException("Scenario class must be derived from USimScenario to run in USim"); |
|||
} |
|||
|
|||
void CreateLinuxBuildAndZip() |
|||
{ |
|||
// Create build directory
|
|||
var projectBuildDirectory = $"{m_BuildDirectory}/{m_RunNameField.value}"; |
|||
if (!Directory.Exists(projectBuildDirectory)) |
|||
Directory.CreateDirectory(projectBuildDirectory); |
|||
|
|||
// Create Linux build
|
|||
Debug.Log("Creating Linux build..."); |
|||
var buildPlayerOptions = new BuildPlayerOptions |
|||
{ |
|||
scenes = new[] { AssetDatabase.GetAssetPath(m_MainSceneField.value) }, |
|||
locationPathName = Path.Combine(projectBuildDirectory, $"{m_RunNameField.value}.x86_64"), |
|||
target = BuildTarget.StandaloneLinux64 |
|||
}; |
|||
var report = BuildPipeline.BuildPlayer(buildPlayerOptions); |
|||
var summary = report.summary; |
|||
if (summary.result != BuildResult.Succeeded) |
|||
throw new Exception($"Build did not succeed: status = {summary.result}"); |
|||
Debug.Log("Created Linux build"); |
|||
|
|||
// Zip the build
|
|||
Debug.Log("Starting to zip..."); |
|||
Zip.DirectoryContents(projectBuildDirectory, m_RunNameField.value); |
|||
m_BuildZipPath = projectBuildDirectory + ".zip"; |
|||
Debug.Log("Created build zip"); |
|||
} |
|||
|
|||
List<AppParam> GenerateAppParamIds(CancellationToken token) |
|||
{ |
|||
var appParamIds = new List<AppParam>(); |
|||
for (var i = 0; i < m_InstanceCountField.value; i++) |
|||
{ |
|||
if (token.IsCancellationRequested) |
|||
return null; |
|||
var appParamName = $"{m_RunNameField.value}_{i}"; |
|||
var appParamId = API.UploadAppParam(appParamName, new USimConstants |
|||
{ |
|||
totalIterations = m_TotalIterationsField.value, |
|||
instanceCount = m_InstanceCountField.value, |
|||
instanceIndex = i |
|||
}); |
|||
appParamIds.Add(new AppParam() |
|||
{ |
|||
id = appParamId, |
|||
name = appParamName, |
|||
num_instances = 1 |
|||
}); |
|||
} |
|||
return appParamIds; |
|||
} |
|||
|
|||
async Task StartUSimRun() |
|||
{ |
|||
m_RunButton.SetEnabled(false); |
|||
var cancellationTokenSource = new CancellationTokenSource(); |
|||
var token = cancellationTokenSource.Token; |
|||
|
|||
Debug.Log("Uploading build..."); |
|||
var buildId = await API.UploadBuildAsync( |
|||
m_RunNameField.value, |
|||
m_BuildZipPath, |
|||
cancellationTokenSource: cancellationTokenSource); |
|||
Debug.Log($"Build upload complete: build id {buildId}"); |
|||
|
|||
var appParams = GenerateAppParamIds(token); |
|||
if (token.IsCancellationRequested) |
|||
{ |
|||
Debug.Log("Run cancelled"); |
|||
return; |
|||
} |
|||
Debug.Log($"Generated app-param ids: {appParams.Count}"); |
|||
|
|||
var runDefinitionId = API.UploadRunDefinition(new RunDefinition |
|||
{ |
|||
app_params = appParams.ToArray(), |
|||
name = m_RunNameField.value, |
|||
sys_param_id = m_SysParam.id, |
|||
build_id = buildId |
|||
}); |
|||
Debug.Log($"Run definition upload complete: run definition id {runDefinitionId}"); |
|||
|
|||
var run = Run.CreateFromDefinitionId(runDefinitionId); |
|||
run.Execute(); |
|||
cancellationTokenSource.Dispose(); |
|||
Debug.Log($"Executing run: {run.executionId}"); |
|||
m_RunButton.SetEnabled(true); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEditor; |
|||
using UnityEngine.Experimental.Perception.Randomization.Parameters; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor.PropertyDrawers |
|||
{ |
|||
[CustomPropertyDrawer(typeof(ColorHsva), true)] |
|||
class ColorHsvaDrawer : PropertyDrawer |
|||
{ |
|||
public override VisualElement CreatePropertyGUI(SerializedProperty property) |
|||
{ |
|||
return new ColorHsvaField(property); |
|||
} |
|||
|
|||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) |
|||
{ |
|||
EditorGUI.PropertyField(position, property, label, true); |
|||
} |
|||
|
|||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) |
|||
{ |
|||
return EditorGUI.GetPropertyHeight(property); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: e2ea91ddb1134cc6a14d2e3859a275f5 |
|||
timeCreated: 1600754588 |
|||
======= |
|||
guid: 5e8094c28dd142a09fbbd38ca560164b |
|||
timeCreated: 1598250942 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
using System; |
|||
using UnityEditor; |
|||
using UnityEngine.Experimental.Perception.Randomization.Parameters; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor.PropertyDrawers |
|||
{ |
|||
[CustomPropertyDrawer(typeof(Parameter), true)] |
|||
class ParameterDrawer : PropertyDrawer |
|||
{ |
|||
public override VisualElement CreatePropertyGUI(SerializedProperty property) |
|||
{ |
|||
return new DrawerParameterElement(property); |
|||
} |
|||
|
|||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) |
|||
{ |
|||
EditorGUI.PropertyField(position, property, label, true); |
|||
} |
|||
|
|||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) |
|||
{ |
|||
return EditorGUI.GetPropertyHeight(property); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: e396dea59a4843529416020c3d0ef5af |
|||
timeCreated: 1600754588 |
|||
======= |
|||
guid: d389620d3aa3471ca1877eb59cdfb465 |
|||
timeCreated: 1598135745 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
<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> |
|
|||
<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> |
|
|||
<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> |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: fbfd6bfda79247c1a4578907f9df9d6c |
|||
timeCreated: 1600754588 |
|||
======= |
|||
guid: 6a4bb3efae29429292ccdfa63e661872 |
|||
timeCreated: 1598240583 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
<UXML xmlns="UnityEngine.UIElements"> |
|||
<VisualElement> |
|||
<Style src="../../Uss/Styles.uss"/> |
|||
<VisualElement name="properties"/> |
|||
</VisualElement> |
|||
</UXML> |
|
|||
fileFormatVersion: 2 |
|||
guid: 158d437640f24d70822be92bba46591b |
|||
timeCreated: 1600837112 |
|
|||
fileFormatVersion: 2 |
|||
guid: f792ce75baa443b1bc1c6e4e19f79b5b |
|||
timeCreated: 1600991861 |
|
|||
fileFormatVersion: 2 |
|||
guid: f68d0e4ae9a94881adad2ff4835cddaf |
|||
timeCreated: 1600290113 |
|
|||
fileFormatVersion: 2 |
|||
guid: 61284b57145a4b87b960f780ead021cb |
|||
timeCreated: 1600368801 |
|
|||
<UXML xmlns="UnityEngine.UIElements"> |
|||
<VisualElement name="container" style="width: 225px; height: 300px; background-color: #383838; border-width: 1px; border-color: #232323;"> |
|||
<Style src="../../Uss/Styles.uss"/> |
|||
<TextField name="search-bar" class="randomizer__menu-search-bar" style="padding: 3px;"/> |
|||
<VisualElement name="directory-label" style="flex-direction: row; justify-content: space-between; align-items: center; background-color: #414141"> |
|||
<VisualElement name="directory-chevron" class="randomization__chevron-left"/> |
|||
<TextElement name="directory-label-text" text="Randomizers" style="-unity-font-style: bold; padding: 3px;"/> |
|||
<VisualElement/> |
|||
</VisualElement> |
|||
<VisualElement name="menu-options"/> |
|||
<VisualElement class="randomizer__menu-search-icon"/> |
|||
</VisualElement> |
|||
</UXML> |
|
|||
<UXML xmlns="UnityEngine.UIElements"> |
|||
<VisualElement style="flex-direction: row; justify-content: space-between; align-items: center;" class="randomizer__add-menu-directory-item"> |
|||
<TextElement name="directory" style="margin-right: 10px;"/> |
|||
<VisualElement class="randomization__chevron-right"/> |
|||
</VisualElement> |
|||
</UXML> |
|
|||
<UXML xmlns="UnityEngine.UIElements"> |
|||
<VisualElement class="randomizer__element"> |
|||
<VisualElement name="drag-handle" class="randomizer__drag-handle"/> |
|||
<VisualElement style="flex-grow: 1;"> |
|||
<VisualElement style="flex-direction: row; justify-content: space-between;"> |
|||
<VisualElement style="flex-direction: row; align-items: center;"> |
|||
<VisualElement name="collapse" class="randomization__collapse-toggle foldout-open"/> |
|||
<Toggle name="enabled"/> |
|||
<TextElement name="class-name" text="Randomizer Class Name"/> |
|||
</VisualElement> |
|||
<Button name="remove" class="randomization__remove-item-button"/> |
|||
</VisualElement> |
|||
<VisualElement name="properties" class="randomization__collapsible-container" style="padding-left: 16px;"/> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
</UXML> |
|
|||
<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"/> |
|||
<Button name="collapse-all" text="Collapse All"/> |
|||
</VisualElement> |
|||
</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> |
|
|||
fileFormatVersion: 2 |
|||
guid: 198e373f78464aa7a4bf4211e82434dc |
|||
timeCreated: 1601669088 |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: 5b6d309152934df99cfff89a96b9703e |
|||
timeCreated: 1600754567 |
|||
======= |
|||
guid: 3066f77d411047baafb6cc454adc6e37 |
|||
timeCreated: 1595535184 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
using UnityEditor; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.Experimental.Perception.Randomization.Parameters; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
class ColorHsvaField : ColorField |
|||
{ |
|||
SerializedProperty m_Property; |
|||
SerializedProperty m_H; |
|||
SerializedProperty m_S; |
|||
SerializedProperty m_V; |
|||
SerializedProperty m_A; |
|||
|
|||
public ColorHsvaField(SerializedProperty property) |
|||
{ |
|||
m_Property = property; |
|||
label = m_Property.displayName; |
|||
|
|||
m_H = m_Property.FindPropertyRelative("h"); |
|||
m_S = m_Property.FindPropertyRelative("s"); |
|||
m_V = m_Property.FindPropertyRelative("v"); |
|||
m_A = m_Property.FindPropertyRelative("a"); |
|||
|
|||
rawValue = (Color)new ColorHsva(m_H.floatValue, m_S.floatValue, m_V.floatValue, m_A.floatValue); |
|||
|
|||
this.RegisterValueChangedCallback(evt => |
|||
{ |
|||
var color = (ColorHsva)evt.newValue; |
|||
m_H.floatValue = color.h; |
|||
m_S.floatValue = color.s; |
|||
m_V.floatValue = color.v; |
|||
m_A.floatValue = color.a; |
|||
m_Property.serializedObject.ApplyModifiedProperties(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: c70590a385e44f6fbe82f5c74cb92f71 |
|||
timeCreated: 1600754567 |
|||
======= |
|||
guid: 103b163a2467415ab86b0df8175b12a6 |
|||
timeCreated: 1598254290 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
using UnityEditor; |
|||
using UnityEngine.Experimental.Perception.Randomization.Editor; |
|||
using UnityEngine.Experimental.Perception.Randomization.Parameters; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
class DrawerParameterElement : VisualElement |
|||
{ |
|||
Parameter m_Parameter; |
|||
SerializedProperty m_Collapsed; |
|||
SerializedProperty m_Property; |
|||
const string k_CollapsedParameterClass = "collapsed"; |
|||
|
|||
bool collapsed |
|||
{ |
|||
get => m_Collapsed.boolValue; |
|||
set |
|||
{ |
|||
m_Collapsed.boolValue = value; |
|||
m_Property.serializedObject.ApplyModifiedPropertiesWithoutUndo(); |
|||
if (value) |
|||
AddToClassList(k_CollapsedParameterClass); |
|||
else |
|||
RemoveFromClassList(k_CollapsedParameterClass); |
|||
} |
|||
} |
|||
|
|||
public DrawerParameterElement(SerializedProperty property) |
|||
{ |
|||
m_Property = property; |
|||
m_Collapsed = property.FindPropertyRelative("collapsed"); |
|||
|
|||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/Parameter/ParameterDrawer.uxml").CloneTree(this); |
|||
|
|||
var collapseToggle = this.Q<VisualElement>("collapse"); |
|||
collapseToggle.RegisterCallback<MouseUpEvent>(evt => collapsed = !collapsed); |
|||
collapsed = m_Collapsed.boolValue; |
|||
|
|||
var fieldNameField = this.Q<Label>("field-name"); |
|||
fieldNameField.text = property.displayName; |
|||
|
|||
var drawer = this.Q<VisualElement>("drawer"); |
|||
drawer.Add(new ParameterElement(property)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: a9f0d234cfc24a8da54ec04d5ec9a129 |
|||
timeCreated: 1600754567 |
|||
======= |
|||
guid: e2eb905ca8c14b5cbe43e48418948be0 |
|||
timeCreated: 1598255728 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.Experimental.Perception.Randomization.Editor; |
|||
using UnityEngine.Experimental.Perception.Randomization.Parameters; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
class ParameterElement : VisualElement |
|||
{ |
|||
VisualElement m_PropertiesContainer; |
|||
SerializedProperty m_SerializedProperty; |
|||
|
|||
Parameter parameter => (Parameter)StaticData.GetManagedReferenceValue(m_SerializedProperty); |
|||
CategoricalParameterBase categoricalParameter => (CategoricalParameterBase)parameter; |
|||
|
|||
public ParameterElement(SerializedProperty property) |
|||
{ |
|||
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/Parameter/ParameterElement.uxml"); |
|||
template.CloneTree(this); |
|||
m_SerializedProperty = property; |
|||
m_PropertiesContainer = this.Q<VisualElement>("properties"); |
|||
CreatePropertyFields(); |
|||
} |
|||
|
|||
void CreatePropertyFields() |
|||
{ |
|||
m_PropertiesContainer.Clear(); |
|||
|
|||
if (parameter is CategoricalParameterBase) |
|||
{ |
|||
CreateCategoricalParameterFields(); |
|||
return; |
|||
} |
|||
|
|||
var currentProperty = m_SerializedProperty.Copy(); |
|||
var nextSiblingProperty = m_SerializedProperty.Copy(); |
|||
nextSiblingProperty.NextVisible(false); |
|||
if (currentProperty.NextVisible(true)) |
|||
{ |
|||
do |
|||
{ |
|||
if (SerializedProperty.EqualContents(currentProperty, nextSiblingProperty)) |
|||
break; |
|||
if (currentProperty.type.Contains("managedReference") && |
|||
currentProperty.managedReferenceFieldTypename == StaticData.samplerSerializedFieldType) |
|||
m_PropertiesContainer.Add(new SamplerElement(currentProperty.Copy(), parameter)); |
|||
else |
|||
{ |
|||
var propertyField = new PropertyField(currentProperty.Copy()); |
|||
propertyField.Bind(currentProperty.serializedObject); |
|||
m_PropertiesContainer.Add(propertyField); |
|||
} |
|||
} while (currentProperty.NextVisible(false)); |
|||
} |
|||
} |
|||
|
|||
void CreateCategoricalParameterFields() |
|||
{ |
|||
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/Parameter/CategoricalParameterTemplate.uxml").CloneTree(); |
|||
|
|||
var optionsProperty = m_SerializedProperty.FindPropertyRelative("m_Categories"); |
|||
var probabilitiesProperty = m_SerializedProperty.FindPropertyRelative("probabilities"); |
|||
var probabilities = categoricalParameter.probabilities; |
|||
|
|||
var listView = template.Q<ListView>("options"); |
|||
listView.itemsSource = probabilities; |
|||
listView.itemHeight = 22; |
|||
listView.selectionType = SelectionType.None; |
|||
listView.style.flexGrow = 1.0f; |
|||
listView.style.height = new StyleLength(listView.itemHeight * 4); |
|||
|
|||
VisualElement MakeItem() => new CategoricalOptionElement( |
|||
optionsProperty, probabilitiesProperty); |
|||
listView.makeItem = MakeItem; |
|||
|
|||
void BindItem(VisualElement e, int i) |
|||
{ |
|||
var optionElement = (CategoricalOptionElement)e; |
|||
optionElement.BindProperties(i); |
|||
var removeButton = optionElement.Q<Button>("remove"); |
|||
removeButton.clicked += () => |
|||
{ |
|||
probabilitiesProperty.DeleteArrayElementAtIndex(i); |
|||
|
|||
// First delete sets option to null, second delete removes option
|
|||
var numOptions = optionsProperty.arraySize; |
|||
optionsProperty.DeleteArrayElementAtIndex(i); |
|||
if (numOptions == optionsProperty.arraySize) |
|||
optionsProperty.DeleteArrayElementAtIndex(i); |
|||
|
|||
m_SerializedProperty.serializedObject.ApplyModifiedProperties(); |
|||
listView.itemsSource = categoricalParameter.probabilities; |
|||
listView.Refresh(); |
|||
}; |
|||
} |
|||
listView.bindItem = BindItem; |
|||
|
|||
var addOptionButton = template.Q<Button>("add-option"); |
|||
addOptionButton.clicked += () => |
|||
{ |
|||
probabilitiesProperty.arraySize++; |
|||
optionsProperty.arraySize++; |
|||
m_SerializedProperty.serializedObject.ApplyModifiedProperties(); |
|||
listView.itemsSource = categoricalParameter.probabilities; |
|||
listView.Refresh(); |
|||
listView.ScrollToItem(probabilitiesProperty.arraySize); |
|||
}; |
|||
|
|||
var addFolderButton = template.Q<Button>("add-folder"); |
|||
if (categoricalParameter.sampleType.IsSubclassOf(typeof(Object))) |
|||
{ |
|||
addFolderButton.clicked += () => |
|||
{ |
|||
var folderPath = EditorUtility.OpenFolderPanel( |
|||
"Add Options From Folder", Application.dataPath, string.Empty); |
|||
if (folderPath == string.Empty) |
|||
return; |
|||
var categories = LoadAssetsFromFolder(folderPath, categoricalParameter.sampleType); |
|||
probabilitiesProperty.arraySize += categories.Count; |
|||
optionsProperty.arraySize += categories.Count; |
|||
var uniformProbability = 1f / categories.Count; |
|||
for (var i = 0; i < categories.Count; i++) |
|||
{ |
|||
var optionProperty = optionsProperty.GetArrayElementAtIndex(i); |
|||
var probabilityProperty = probabilitiesProperty.GetArrayElementAtIndex(i); |
|||
optionProperty.objectReferenceValue = categories[i]; |
|||
probabilityProperty.floatValue = uniformProbability; |
|||
} |
|||
m_SerializedProperty.serializedObject.ApplyModifiedProperties(); |
|||
listView.itemsSource = categoricalParameter.probabilities; |
|||
listView.Refresh(); |
|||
}; |
|||
} |
|||
else |
|||
addFolderButton.style.display = new StyleEnum<DisplayStyle>(DisplayStyle.None); |
|||
|
|||
var clearOptionsButton = template.Q<Button>("clear-options"); |
|||
clearOptionsButton.clicked += () => |
|||
{ |
|||
probabilitiesProperty.arraySize = 0; |
|||
optionsProperty.arraySize = 0; |
|||
m_SerializedProperty.serializedObject.ApplyModifiedProperties(); |
|||
listView.itemsSource = categoricalParameter.probabilities; |
|||
listView.Refresh(); |
|||
}; |
|||
|
|||
var scrollView = listView.Q<ScrollView>(); |
|||
listView.RegisterCallback<WheelEvent>(evt => |
|||
{ |
|||
if (Mathf.Approximately(scrollView.verticalScroller.highValue, 0f)) |
|||
return; |
|||
if ((scrollView.scrollOffset.y <= 0f && evt.delta.y < 0f) || |
|||
scrollView.scrollOffset.y >= scrollView.verticalScroller.highValue && evt.delta.y > 0f) |
|||
evt.StopImmediatePropagation(); |
|||
}); |
|||
|
|||
var uniformToggle = template.Q<Toggle>("uniform"); |
|||
var uniformProperty = m_SerializedProperty.FindPropertyRelative("uniform"); |
|||
uniformToggle.BindProperty(uniformProperty); |
|||
void ToggleProbabilityFields(bool toggle) |
|||
{ |
|||
if (toggle) |
|||
listView.AddToClassList("collapsed"); |
|||
else |
|||
listView.RemoveFromClassList("collapsed"); |
|||
} |
|||
ToggleProbabilityFields(uniformToggle.value); |
|||
if (Application.isPlaying) |
|||
uniformToggle.SetEnabled(false); |
|||
else |
|||
uniformToggle.RegisterCallback<ChangeEvent<bool>>(evt => ToggleProbabilityFields(evt.newValue)); |
|||
|
|||
var seedField = template.Q<IntegerField>("seed"); |
|||
seedField.BindProperty(m_SerializedProperty.FindPropertyRelative("m_Sampler.<baseSeed>k__BackingField")); |
|||
|
|||
m_PropertiesContainer.Add(template); |
|||
} |
|||
|
|||
static List<Object> LoadAssetsFromFolder(string folderPath, Type assetType) |
|||
{ |
|||
if (!folderPath.StartsWith(Application.dataPath)) |
|||
throw new ApplicationException("Selected folder is not an asset folder in this project"); |
|||
var assetsPath = "Assets" + folderPath.Remove(0, Application.dataPath.Length); |
|||
var assetIds = AssetDatabase.FindAssets($"t:{assetType.Name}", new []{assetsPath}); |
|||
var assets = new List<Object>(); |
|||
foreach (var guid in assetIds) |
|||
assets.Add(AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), assetType)); |
|||
return assets; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
<<<<<<< HEAD |
|||
guid: b15caa7425ab4b9a8367bd544ab4730d |
|||
timeCreated: 1600754567 |
|||
======= |
|||
guid: ea72d77c64d1447aa195e2068f02cf74 |
|||
timeCreated: 1595279847 |
|||
>>>>>>> 86d25d2... implemented parameter behaviours |
|
|||
fileFormatVersion: 2 |
|||
guid: c194e9893fcc4197ab26d01371347d07 |
|||
timeCreated: 1601054944 |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue