比较提交
合并到: unity-tech-cn:main
unity-tech-cn:/main
unity-tech-cn:/readback_mode
unity-tech-cn:/fix-editor-pause
unity-tech-cn:/docs
unity-tech-cn:/format
unity-tech-cn:/dr-test1
unity-tech-cn:/fix-compile
unity-tech-cn:/fix-links
unity-tech-cn:/fix_startup_exception
unity-tech-cn:/fix-docs
unity-tech-cn:/fix_label_id_report
unity-tech-cn:/update-setup-steps
unity-tech-cn:/labeler_mock
unity-tech-cn:/publish-fix
unity-tech-cn:/result_visualization
unity-tech-cn:/labeler_mock_mb
unity-tech-cn:/labeler_mock_on_camera
unity-tech-cn:/0.1.0-staging
unity-tech-cn:/dr-test2
unity-tech-cn:/release_cleanup
unity-tech-cn:/RC_0.2.0-preview.1
unity-tech-cn:/aisv614_0.2.0
unity-tech-cn:/aisv614_fix
unity-tech-cn:/aisv647_visualizations
unity-tech-cn:/RC-0.2.0-preview.1
unity-tech-cn:/fix_seg_colors
unity-tech-cn:/test
unity-tech-cn:/0.3.0-staging
unity-tech-cn:/aisv565_bbox3d
unity-tech-cn:/aisv749_viz_mem_leak_bug
unity-tech-cn:/aisv754_seg_alpha_bug
unity-tech-cn:/test_request_tracking_completion
unity-tech-cn:/test_new_versions
unity-tech-cn:/usim-randomization
unity-tech-cn:/with_cloud_tests
unity-tech-cn:/0.2.0-staging
unity-tech-cn:/parameter-bahaviours
unity-tech-cn:/upgrade_deps
unity-tech-cn:/0.4.0-staging
unity-tech-cn:/0.5.0-staging-2020.1
unity-tech-cn:/0.5.0-staging
unity-tech-cn:/resint_updates
unity-tech-cn:/tutorial-spelling-fix
unity-tech-cn:/priyesh-urp-dist-render
unity-tech-cn:/multiple-perception-cameras
unity-tech-cn:/pre_release_tests_nov2020
unity-tech-cn:/0.6.0-staging
unity-tech-cn:/fix_performance_tests
unity-tech-cn:/manual_capture
unity-tech-cn:/fod_generator_randomization_changes
unity-tech-cn:/multipleCameras
unity-tech-cn:/Labelbug1101
unity-tech-cn:/replace_index_md
unity-tech-cn:/depth_occlusion
unity-tech-cn:/0.8.0-preview.1_staging
unity-tech-cn:/validation-tool
unity-tech-cn:/addressables-test
unity-tech-cn:/int_tests_on_hdrp
unity-tech-cn:/keypoint_self_occlusion
unity-tech-cn:/seg_opacity
unity-tech-cn:/foreground_object_bounds_normalization
unity-tech-cn:/generic-asset-sources
unity-tech-cn:/local-position-labeler
unity-tech-cn:/pyrception-integration
unity-tech-cn:/fix_sampler_rounding_issue
unity-tech-cn:/h-i
unity-tech-cn:/0.7.0-staging
unity-tech-cn:/Released-0.6.0-preview.1
unity-tech-cn:/moved-from-attribute
unity-tech-cn:/frontpage_shuffle
unity-tech-cn:/coco_export
unity-tech-cn:/public-spec
unity-tech-cn:/fix-3Dexception-typo
unity-tech-cn:/feat-light-randomizer
unity-tech-cn:/schema-0.1.0
unity-tech-cn:/data-cap-update
unity-tech-cn:/0.8.0.preview.4_staging
unity-tech-cn:/faq-page
unity-tech-cn:/orthographic-camera-metadata
unity-tech-cn:/update-docs-0.8.0.preview.4
unity-tech-cn:/priyesh-cloudrendering-test
unity-tech-cn:/Release_0.8.0-preview.4
unity-tech-cn:/tutorial_patch
unity-tech-cn:/add_imageLink_field
unity-tech-cn:/fix_label_config_editor_indexing
unity-tech-cn:/coco_perception_output_hybrid
unity-tech-cn:/fxaa-clarification
unity-tech-cn:/no_editor_coverage
unity-tech-cn:/keypoint_self_occlusion_2020_3
unity-tech-cn:/for_vulkan_mem_test
unity-tech-cn:/solo_support
unity-tech-cn:/fix_multi_cam
unity-tech-cn:/randomizer-serialization-update
unity-tech-cn:/semantic_shader_tests
unity-tech-cn:/revert-sample-scene
unity-tech-cn:/package-analytics
unity-tech-cn:/github-action
unity-tech-cn:/fix-one-extra-frame-before-scenario-starts
unity-tech-cn:/scene_gen
unity-tech-cn:/0.9.0.preview.1_staging
unity-tech-cn:/tag-RC-0.9.0.preview.2
unity-tech-cn:/remove-usim-from-docs
unity-tech-cn:/docs/fix-readme-image-names
unity-tech-cn:/fix-links/jonh
unity-tech-cn:/addressables-test/scheduledcapture
unity-tech-cn:/orthographic-camera-metadata/additions
unity-tech-cn:/github-action/test
拉取从: unity-tech-cn:usim-randomization
unity-tech-cn:/main
unity-tech-cn:/readback_mode
unity-tech-cn:/fix-editor-pause
unity-tech-cn:/docs
unity-tech-cn:/format
unity-tech-cn:/dr-test1
unity-tech-cn:/fix-compile
unity-tech-cn:/fix-links
unity-tech-cn:/fix_startup_exception
unity-tech-cn:/fix-docs
unity-tech-cn:/fix_label_id_report
unity-tech-cn:/update-setup-steps
unity-tech-cn:/labeler_mock
unity-tech-cn:/publish-fix
unity-tech-cn:/result_visualization
unity-tech-cn:/labeler_mock_mb
unity-tech-cn:/labeler_mock_on_camera
unity-tech-cn:/0.1.0-staging
unity-tech-cn:/dr-test2
unity-tech-cn:/release_cleanup
unity-tech-cn:/RC_0.2.0-preview.1
unity-tech-cn:/aisv614_0.2.0
unity-tech-cn:/aisv614_fix
unity-tech-cn:/aisv647_visualizations
unity-tech-cn:/RC-0.2.0-preview.1
unity-tech-cn:/fix_seg_colors
unity-tech-cn:/test
unity-tech-cn:/0.3.0-staging
unity-tech-cn:/aisv565_bbox3d
unity-tech-cn:/aisv749_viz_mem_leak_bug
unity-tech-cn:/aisv754_seg_alpha_bug
unity-tech-cn:/test_request_tracking_completion
unity-tech-cn:/test_new_versions
unity-tech-cn:/usim-randomization
unity-tech-cn:/with_cloud_tests
unity-tech-cn:/0.2.0-staging
unity-tech-cn:/parameter-bahaviours
unity-tech-cn:/upgrade_deps
unity-tech-cn:/0.4.0-staging
unity-tech-cn:/0.5.0-staging-2020.1
unity-tech-cn:/0.5.0-staging
unity-tech-cn:/resint_updates
unity-tech-cn:/tutorial-spelling-fix
unity-tech-cn:/priyesh-urp-dist-render
unity-tech-cn:/multiple-perception-cameras
unity-tech-cn:/pre_release_tests_nov2020
unity-tech-cn:/0.6.0-staging
unity-tech-cn:/fix_performance_tests
unity-tech-cn:/manual_capture
unity-tech-cn:/fod_generator_randomization_changes
unity-tech-cn:/multipleCameras
unity-tech-cn:/Labelbug1101
unity-tech-cn:/replace_index_md
unity-tech-cn:/depth_occlusion
unity-tech-cn:/0.8.0-preview.1_staging
unity-tech-cn:/validation-tool
unity-tech-cn:/addressables-test
unity-tech-cn:/int_tests_on_hdrp
unity-tech-cn:/keypoint_self_occlusion
unity-tech-cn:/seg_opacity
unity-tech-cn:/foreground_object_bounds_normalization
unity-tech-cn:/generic-asset-sources
unity-tech-cn:/local-position-labeler
unity-tech-cn:/pyrception-integration
unity-tech-cn:/fix_sampler_rounding_issue
unity-tech-cn:/h-i
unity-tech-cn:/0.7.0-staging
unity-tech-cn:/Released-0.6.0-preview.1
unity-tech-cn:/moved-from-attribute
unity-tech-cn:/frontpage_shuffle
unity-tech-cn:/coco_export
unity-tech-cn:/public-spec
unity-tech-cn:/fix-3Dexception-typo
unity-tech-cn:/feat-light-randomizer
unity-tech-cn:/schema-0.1.0
unity-tech-cn:/data-cap-update
unity-tech-cn:/0.8.0.preview.4_staging
unity-tech-cn:/faq-page
unity-tech-cn:/orthographic-camera-metadata
unity-tech-cn:/update-docs-0.8.0.preview.4
unity-tech-cn:/priyesh-cloudrendering-test
unity-tech-cn:/Release_0.8.0-preview.4
unity-tech-cn:/tutorial_patch
unity-tech-cn:/add_imageLink_field
unity-tech-cn:/fix_label_config_editor_indexing
unity-tech-cn:/coco_perception_output_hybrid
unity-tech-cn:/fxaa-clarification
unity-tech-cn:/no_editor_coverage
unity-tech-cn:/keypoint_self_occlusion_2020_3
unity-tech-cn:/for_vulkan_mem_test
unity-tech-cn:/solo_support
unity-tech-cn:/fix_multi_cam
unity-tech-cn:/randomizer-serialization-update
unity-tech-cn:/semantic_shader_tests
unity-tech-cn:/revert-sample-scene
unity-tech-cn:/package-analytics
unity-tech-cn:/github-action
unity-tech-cn:/fix-one-extra-frame-before-scenario-starts
unity-tech-cn:/scene_gen
unity-tech-cn:/0.9.0.preview.1_staging
unity-tech-cn:/tag-RC-0.9.0.preview.2
unity-tech-cn:/remove-usim-from-docs
unity-tech-cn:/docs/fix-readme-image-names
unity-tech-cn:/fix-links/jonh
unity-tech-cn:/addressables-test/scheduledcapture
unity-tech-cn:/orthographic-camera-metadata/additions
unity-tech-cn:/github-action/test
此合并请求有变更与目标分支冲突。
/com.unity.perception/Editor/Unity.Perception.Editor.asmdef
/com.unity.perception/Runtime/Randomization/Scenarios/FixedLengthScenario.cs
/com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs
/com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
/com.unity.perception/Tests/Runtime/Randomization/ScenarioTests.cs
4 次代码提交
作者 | SHA1 | 备注 | 提交日期 |
---|---|---|---|
Steven Leal | 2753d943 | need to fix async await stuff | 4 年前 |
Steven Leal | e7cf2a16 | added usim status fields | 4 年前 |
Steven Leal | 62e505d4 | added run in USim window | 4 年前 |
Steven Leal | 5ce535d7 | added run in usim window | 4 年前 |
共有 17 个文件被更改,包括 516 次插入 和 43 次删除
-
30com.unity.perception/Tests/Runtime/Randomization/ScenarioTests.cs
-
7com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs
-
10com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
-
33com.unity.perception/Runtime/Randomization/Scenarios/FixedLengthScenario.cs
-
6com.unity.perception/Editor/Unity.Perception.Editor.asmdef
-
3com.unity.perception/Runtime/Randomization/Scenarios/USimScenario.cs.meta
-
38com.unity.perception/Runtime/Randomization/Scenarios/USimScenario.cs
-
7com.unity.perception/Runtime/Randomization/Scenarios/USimScenarioBase.cs
-
3com.unity.perception/Runtime/Randomization/Scenarios/USimScenarioBase.cs.meta
-
3com.unity.perception/Editor/Randomization/RunInUSimWindow.cs.meta
-
59com.unity.perception/Editor/Randomization/PositiveIntegerField.cs
-
3com.unity.perception/Editor/Randomization/PositiveIntegerField.cs.meta
-
297com.unity.perception/Editor/Randomization/RunInUSimWindow.cs
-
6com.unity.perception/Editor/Randomization/Uss/RunInUSimStyles.uss
-
3com.unity.perception/Editor/Randomization/Uss/RunInUSimStyles.uss.meta
-
3com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml.meta
-
48com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml
|
|||
fileFormatVersion: 2 |
|||
guid: 1ef5313c07934eeabb46b852ab57ed79 |
|||
timeCreated: 1597102599 |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Scenarios |
|||
{ |
|||
public abstract class USimScenario : Scenario<USimConstants> |
|||
{ |
|||
public override bool isScenarioComplete => currentIteration >= constants.totalIterations; |
|||
|
|||
public override void OnInitialize() |
|||
{ |
|||
currentIteration = constants.instanceIndex; |
|||
} |
|||
|
|||
public override void IncrementIteration() |
|||
{ |
|||
currentIteration += constants.instanceCount; |
|||
} |
|||
|
|||
public override void Deserialize() |
|||
{ |
|||
if (!string.IsNullOrEmpty(Unity.Simulation.Configuration.Instance.SimulationConfig.app_param_uri)) |
|||
{ |
|||
Debug.Log("Reading app-params"); |
|||
constants = Unity.Simulation.Configuration.Instance.GetAppParams<USimConstants>(); |
|||
} |
|||
else |
|||
base.Deserialize(); |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class USimConstants |
|||
{ |
|||
public int totalIterations = 100; |
|||
public int instanceCount = 1; |
|||
public int instanceIndex; |
|||
} |
|||
} |
|
|||
namespace UnityEngine.Perception.Randomization.Scenarios |
|||
{ |
|||
public abstract class USimScenarioBase : ScenarioBase |
|||
{ |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6b9735d0324e476999f22e4731058861 |
|||
timeCreated: 1597687928 |
|
|||
fileFormatVersion: 2 |
|||
guid: 21e030e241504815a3dbaad77a144aca |
|||
timeCreated: 1596820769 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.Mathematics; |
|||
using UnityEditor; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
public class PositiveIntegerField : IntegerField |
|||
{ |
|||
public int maxValue = int.MaxValue; |
|||
|
|||
public PositiveIntegerField() |
|||
{ |
|||
RegisterValueClamping(); |
|||
} |
|||
|
|||
public PositiveIntegerField(int maxValue) |
|||
{ |
|||
this.maxValue = maxValue; |
|||
RegisterValueClamping(); |
|||
} |
|||
|
|||
public PositiveIntegerField(SerializedProperty property, int maxValue=int.MaxValue) : this(maxValue) |
|||
{ |
|||
this.BindProperty(property); |
|||
} |
|||
|
|||
void RegisterValueClamping() |
|||
{ |
|||
this.RegisterValueChangedCallback(evt => |
|||
{ |
|||
value = math.clamp(evt.newValue, 0, maxValue); |
|||
evt.StopImmediatePropagation(); |
|||
}); |
|||
} |
|||
|
|||
public new class UxmlFactory : UxmlFactory<PositiveIntegerField, UxmlTraits> { } |
|||
|
|||
public new class UxmlTraits : IntegerField.UxmlTraits |
|||
{ |
|||
UxmlIntAttributeDescription m_Int = new UxmlIntAttributeDescription { name = "max-value", defaultValue = int.MaxValue }; |
|||
|
|||
public override IEnumerable<UxmlChildElementDescription> uxmlChildElementsDescription |
|||
{ |
|||
get { yield break; } |
|||
} |
|||
|
|||
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc) |
|||
{ |
|||
base.Init(ve, bag, cc); |
|||
if (!(ve is PositiveIntegerField positiveIntegerField)) |
|||
return; |
|||
positiveIntegerField.maxValue = m_Int.GetValueFromBag(bag, cc); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ddab76638f764bac9bd4b213e5cf8ebe |
|||
timeCreated: 1597168414 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Boo.Lang.Runtime; |
|||
using Unity.Simulation.Client; |
|||
using UnityEditor; |
|||
using UnityEditor.Build.Reporting; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.Perception.Randomization.Scenarios; |
|||
using UnityEngine.UIElements; |
|||
using ZipUtility; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
public class RunInUSimWindow : EditorWindow |
|||
{ |
|||
string m_BuildZipPath; |
|||
SysParamDefinition m_SysParam; |
|||
float m_LastRunStatusPing; |
|||
|
|||
TextField m_RunNameField; |
|||
TextField m_RunExecutionIdField; |
|||
VisualElement m_RunStatusContainer; |
|||
IntegerField m_TotalIterationsField; |
|||
IntegerField m_InstanceCountField; |
|||
ObjectField m_MainSceneField; |
|||
ObjectField m_ScenarioField; |
|||
Button m_RunButton; |
|||
|
|||
TextElement m_NumNotRun; |
|||
TextElement m_NumFailures; |
|||
TextElement m_NumInProgress; |
|||
TextElement m_NumSuccess; |
|||
TextElement m_RunState; |
|||
|
|||
[MenuItem("Window/Run in USim")] |
|||
public 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() |
|||
{ |
|||
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>
|
|||
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); |
|||
|
|||
m_ScenarioField = root.Q<ObjectField>("scenario"); |
|||
m_ScenarioField.objectType = typeof(ScenarioBase); |
|||
|
|||
m_RunStatusContainer = root.Q<VisualElement>("run-status-container"); |
|||
m_RunExecutionIdField = root.Q<TextField>("run-execution-id"); |
|||
SetViewDataKey(m_RunExecutionIdField); |
|||
|
|||
m_NumNotRun = root.Q<TextElement>("num-not-run"); |
|||
m_NumFailures = root.Q<TextElement>("num-failures"); |
|||
m_NumInProgress = root.Q<TextElement>("num-in-progress"); |
|||
m_NumSuccess = root.Q<TextElement>("num-success"); |
|||
m_RunState = root.Q<TextElement>("run-state"); |
|||
|
|||
var downloadManifestButton = root.Q<Button>("download-manifest"); |
|||
downloadManifestButton.clicked += DownloadManifest; |
|||
|
|||
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 = sysParamDefinitions[0].description; |
|||
m_SysParam = sysParamDefinitions[0]; |
|||
|
|||
m_RunButton = root.Q<Button>("run-button"); |
|||
m_RunButton.clicked += RunInUSim; |
|||
} |
|||
|
|||
// void ToggleVisibility(VisualElement element, bool visible)
|
|||
// {
|
|||
// Debug.Log(visible);
|
|||
// element.style.display = visible
|
|||
// ? new StyleEnum<DisplayStyle>(DisplayStyle.Flex)
|
|||
// : new StyleEnum<DisplayStyle>(DisplayStyle.None);
|
|||
// }
|
|||
|
|||
void OnInspectorUpdate() |
|||
{ |
|||
if (!string.IsNullOrEmpty(m_RunExecutionIdField.value) && |
|||
m_LastRunStatusPing < Time.realtimeSinceStartup - 3f) |
|||
{ |
|||
m_LastRunStatusPing = Time.realtimeSinceStartup; |
|||
UpdateRunStatus(); |
|||
} |
|||
} |
|||
|
|||
void UpdateRunStatus() |
|||
{ |
|||
var summary = API.Summarize(m_RunExecutionIdField.value); |
|||
Debug.Log(summary.state.code); |
|||
m_NumNotRun.text = summary.num_not_run.ToString(); |
|||
m_NumFailures.text = summary.num_failures.ToString(); |
|||
m_NumInProgress.text = summary.num_in_progress.ToString(); |
|||
m_NumSuccess.text = summary.num_success.ToString(); |
|||
m_RunState.text = summary.state.code; |
|||
} |
|||
|
|||
void DownloadManifest() |
|||
{ |
|||
if (!string.IsNullOrEmpty(m_RunExecutionIdField.value)) |
|||
{ |
|||
var manifest = API.GetManifest(m_RunExecutionIdField.value); |
|||
var manifestFilePath = EditorUtility.SaveFilePanel("Save Manifest", Application.dataPath, "manifest", "csv"); |
|||
var lines = new string[manifest.Count + 1]; |
|||
lines[0] = "run_execution_id,app_param_id,instance_id,attempt_id,file_name,download_uri"; |
|||
var i = 1; |
|||
foreach (var pair in manifest) |
|||
{ |
|||
var e = pair.Value; |
|||
lines[i++] = $"{e.executionId},{e.appParamId},{e.instanceId},{e.attemptId},{e.fileName},{e.downloadUri}"; |
|||
} |
|||
File.WriteAllLines(manifestFilePath, lines); |
|||
} |
|||
} |
|||
|
|||
async void RunInUSim() |
|||
{ |
|||
ValidateSettings(); |
|||
CreateLinuxBuildAndZip(); |
|||
var run = await StartUSimRun(); |
|||
m_RunExecutionIdField.value = run.executionId; |
|||
} |
|||
|
|||
void ValidateSettings() |
|||
{ |
|||
if (string.IsNullOrEmpty(m_RunNameField.value)) |
|||
throw new RuntimeException("Invalid run name"); |
|||
if (m_ScenarioField.value == null) |
|||
throw new RuntimeException("Null scenario"); |
|||
if (m_MainSceneField.value == null) |
|||
throw new RankException("Null main scene"); |
|||
} |
|||
|
|||
void CreateLinuxBuildAndZip() |
|||
{ |
|||
// Ensure that scenario serialization is enabled
|
|||
var scenario = (USimScenario)m_ScenarioField.value; |
|||
scenario.deserializeOnStart = true; |
|||
|
|||
// Create build directory
|
|||
var pathToProjectBuild = Application.dataPath + "/../" + "Build/"; |
|||
if (!Directory.Exists(pathToProjectBuild + m_RunNameField.value)) |
|||
Directory.CreateDirectory(pathToProjectBuild + m_RunNameField.value); |
|||
|
|||
pathToProjectBuild = pathToProjectBuild + m_RunNameField.value + "/"; |
|||
|
|||
// Create Linux build
|
|||
Debug.Log("Creating Linux build..."); |
|||
var buildPlayerOptions = new BuildPlayerOptions |
|||
{ |
|||
scenes = new[] { AssetDatabase.GetAssetPath(m_MainSceneField.value) }, |
|||
locationPathName = Path.Combine(pathToProjectBuild, m_RunNameField.value + ".x86_64"), |
|||
target = BuildTarget.StandaloneLinux64 |
|||
}; |
|||
var report = BuildPipeline.BuildPlayer(buildPlayerOptions); |
|||
var summary = report.summary; |
|||
if (summary.result != BuildResult.Succeeded) |
|||
throw new RuntimeException($"Build did not succeed: status = {summary.result}"); |
|||
Debug.Log("Created Linux build"); |
|||
|
|||
// Zip the build
|
|||
Debug.Log("Starting to zip..."); |
|||
var buildFolder = Application.dataPath + "/../" + "Build/" + m_RunNameField.value; |
|||
Zip.DirectoryContents(buildFolder, m_RunNameField.value); |
|||
m_BuildZipPath = buildFolder + ".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<Run> 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) |
|||
return null; |
|||
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}"); |
|||
return run; |
|||
} |
|||
} |
|||
} |
|
|||
.dark-viewport { |
|||
border-radius: 5px; |
|||
background-color: #191919; |
|||
padding: 2px; |
|||
margin: 2px; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8ee39ab9c50a4f5db26869a0e40a54fa |
|||
timeCreated: 1597718729 |
|
|||
fileFormatVersion: 2 |
|||
guid: 678c5d944639402c9c4d50de04c77561 |
|||
timeCreated: 1596821310 |
|
|||
<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" xmlns:randEditor="UnityEngine.Perception.Randomization.Editor"> |
|||
<VisualElement> |
|||
<Style src="../Uss/RunInUSimStyles.uss"/> |
|||
<VisualElement class="dark-viewport" style="margin-bottom: 20px;"> |
|||
<VisualElement style=""> |
|||
<TextField name="run-name" label="Run Name"/> |
|||
<randEditor:PositiveIntegerField name="total-iterations" label="Total Iterations"/> |
|||
<randEditor:PositiveIntegerField name="instance-count" label="Instance Count" max-value="10000"/> |
|||
<editor:ObjectField name="main-scene" label="Main Scene" allow-scene-objects="false"/> |
|||
<editor:ObjectField name="scenario" label="Scenario"/> |
|||
<VisualElement class="unity-base-field"> |
|||
<Label text="USim worker config" class="unity-base-field__label"/> |
|||
<editor:ToolbarMenu name="sys-param" class="unity-base-field__input" style="border-width: 1px;"/> |
|||
</VisualElement> |
|||
<VisualElement style="align-items: center;"> |
|||
<Button name="run-button" text="Build and Run" style="margin: 10px; padding: 2 20; font-size: 13px;"/> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
|
|||
<VisualElement name="run-status-container" class="dark-viewport"> |
|||
<TextField name="run-execution-id" label="Run Execution ID"/> |
|||
<VisualElement class="unity-base-field"> |
|||
<Label text="Not Run" class="unity-base-field__label"/> |
|||
<TextElement name="num-not-run"/> |
|||
</VisualElement> |
|||
<VisualElement class="unity-base-field"> |
|||
<Label text="Failed" class="unity-base-field__label"/> |
|||
<TextElement name="num-failures"/> |
|||
</VisualElement> |
|||
<VisualElement class="unity-base-field"> |
|||
<Label text="In Progress" class="unity-base-field__label"/> |
|||
<TextElement name="num-in-progress"/> |
|||
</VisualElement> |
|||
<VisualElement class="unity-base-field"> |
|||
<Label text="Succeeded" class="unity-base-field__label"/> |
|||
<TextElement name="num-success"/> |
|||
</VisualElement> |
|||
<VisualElement class="unity-base-field"> |
|||
<Label text="State" class="unity-base-field__label"/> |
|||
<TextElement name="run-state"/> |
|||
</VisualElement> |
|||
<VisualElement style="align-items: center;"> |
|||
<Button name="download-manifest" text="Download Manifest" style="margin: 10px; padding: 2 20; font-size: 13px;"/> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
</UXML> |
撰写
预览
正在加载...
取消
保存
Reference in new issue