浏览代码

Merge pull request #93 from Unity-Technologies/0.5.0-staging

Replaced new with ScriptableObject.CreateInstance<T>()
/main
GitHub 4 年前
当前提交
385f2805
共有 3 个文件被更改,包括 8 次插入7 次删除
  1. 2
      com.unity.perception/Documentation~/Tutorial/Phase1.md
  2. 4
      com.unity.perception/Documentation~/Tutorial/Phase3.md
  3. 9
      com.unity.perception/Tests/Runtime/GroundTruthTests/LabelEntryMatchCacheTests.cs

2
com.unity.perception/Documentation~/Tutorial/Phase1.md


* **Action**: Click on the _**+**_ sign at the top-left corner of the _**Package Manager**_ window and then choose the option _**Add package frim git URL...**_.
* **Action**: Enter the address `com.unity.perception` and click _**Add**_.
**Note:** If you would like a specific version of the package, you can append the version to the end of the url. For example `com.unity.perception@0.1.0-preview.5`. For this tutorial, **we do not need to add a version**. You can also install the package from a local clone of the Perception repository. More inofrmation on installing local pacakges is available [here](https://docs.unity3d.com/Manual/upm-ui-local.html).
**Note:** If you would like a specific version of the package, you can append the version to the end of the url. For example `com.unity.perception@0.1.0-preview.5`. For this tutorial, **we do not need to add a version**. You can also install the package from a local clone of the Perception repository. More information on installing local pacakges is available [here](https://docs.unity3d.com/Manual/upm-ui-local.html).
It will take some time for the manager to download and import the package. Once the operation finishes, you will see the newly download Perception package automatically selected in the _**Package Manager**_, as depicted below:

4
com.unity.perception/Documentation~/Tutorial/Phase3.md


* **Action**: Choose `TutorialScene` (which is the Scene we have been working in) as your _**Main Scene**_ and the `SimulationScenario` object as your _**Scenario**_.
Here, you can also specify a name for the run, the number of iterations the Scenario will execute for, and the number of concurrent _**Instances**_ for the run.
Here, you can also specify a name for the run, the number of iterations the Scenario will execute for, and the number of _**Instances**_ (number of nodes the work will be distributed across) for the run.
* **Action**: Name your run `FirstRun`, set the number of iterations to `1000`, and instances to `1`.
* **Action**: Name your run `FirstRun`, set the number of iterations to `1000`, and instances to `20`.
* **Action**: Click _**Build and Run**_.
Your project will now be built and then uploaded to USim. Depending on the upload speed of your internet connection, this might take anywhere from a few seconds to a couple of minutes.

9
com.unity.perception/Tests/Runtime/GroundTruthTests/LabelEntryMatchCacheTests.cs


using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.TestTools;

[Test]
public void TryGet_ReturnsFalse_ForInvalidInstanceId()
{
var config = new IdLabelConfig();
var config = ScriptableObject.CreateInstance<IdLabelConfig>();
using (var cache = new LabelEntryMatchCache(config))
{
Assert.IsFalse(cache.TryGetLabelEntryFromInstanceId(100, out var labelEntry, out var index));

var label = "label";
var labeledPlane = TestHelper.CreateLabeledPlane(label: label);
AddTestObjectForCleanup(labeledPlane);
var config = new IdLabelConfig();
var config = ScriptableObject.CreateInstance<IdLabelConfig>();
config.Init(new[]
{
new IdLabelEntry()

var label = "label";
var labeledPlane = TestHelper.CreateLabeledPlane(label: label);
AddTestObjectForCleanup(labeledPlane);
var config = new IdLabelConfig();
var config = ScriptableObject.CreateInstance<IdLabelConfig>();
using (var cache = new LabelEntryMatchCache(config))
{
//allow label to be registered

yield return null;
var labeledPlane2 = TestHelper.CreateLabeledPlane(label: label);
AddTestObjectForCleanup(labeledPlane2);
var config = new IdLabelConfig();
var config = ScriptableObject.CreateInstance<IdLabelConfig>();
config.Init(new[]
{
new IdLabelEntry()

正在加载...
取消
保存