浏览代码

PR fixes

Some fairly major UI architecture changes to address comments made during the initial cut PR. Things make more sense now.
/aisv647_visualizations
Steven Borkman 4 年前
当前提交
217716eb
共有 51 个文件被更改,包括 883 次插入232 次删除
  1. 66
      TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
  2. 36
      com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs
  3. 157
      com.unity.perception/Runtime/GroundTruth/Labelers/CameraLabeler.cs
  4. 27
      com.unity.perception/Runtime/GroundTruth/Labelers/ObjectCountLabeler.cs
  5. 31
      com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs
  6. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/Resources.meta
  7. 41
      com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
  8. 6
      com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs
  9. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat
  10. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/KeyValuePanel.prefab
  11. 8
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization.meta
  12. 128
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/ControlPanel.cs
  13. 11
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/ControlPanel.cs.meta
  14. 33
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/KeyValuePanel.cs
  15. 8
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials.meta
  16. 8
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat.meta
  17. 8
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources.meta
  18. 450
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/VisualizationUI.prefab
  19. 7
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/VisualizationUI.prefab.meta
  20. 8
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures.meta
  21. 65
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/VisualizationCanvas.cs
  22. 11
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/VisualizationCanvas.cs.meta
  23. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/BoundingBoxPrefab.prefab
  24. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/BoundingBoxPrefab.prefab.meta
  25. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/GenericSlider.prefab
  26. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/GenericSlider.prefab.meta
  27. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/GenericToggle.prefab
  28. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/GenericToggle.prefab.meta
  29. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/Inter-Light.otf
  30. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/Inter-Light.otf.meta
  31. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/OutlineMaterial.mat
  32. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/OutlineMaterial.mat.meta
  33. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegmentTexture.prefab
  34. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegmentTexture.prefab.meta
  35. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures/outline_box.png
  36. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures/outline_box.png.meta
  37. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures/sharp_done_white_18dp.png
  38. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures/sharp_done_white_18dp.png.meta
  39. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegRemoveBackgroundShader.shader.meta
  40. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegRemoveBackgroundShader.shader
  41. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat
  42. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/HUDPanel.cs
  43. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/HUDPanel.cs.meta
  44. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/KeyValuePanel.cs.meta
  45. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/KeyValuePanel.prefab
  46. 0
      /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/KeyValuePanel.prefab.meta

66
TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity


m_EditorClassIdentifier:
light: {fileID: 705507993}
target: {fileID: 1640252278}
--- !u!1 &1251615276
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1251615279}
- component: {fileID: 1251615278}
- component: {fileID: 1251615277}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1251615277
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1251615276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1251615278
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1251615276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1251615279
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1251615276}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1640252278
GameObject:
m_ObjectHideFlags: 0

36
com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs


}
/// <inheritdoc/>
protected override bool supportsVisualization => true;
/// <inheritdoc/>
protected override void Setup()
{
if (idLabelConfig == null)

perceptionCamera.RenderedObjectInfosCalculated += OnRenderedObjectInfosCalculated;
supportsVisualization = true;
EnableVisualization(supportsVisualization);
visualizationEnabled = supportsVisualization;
}
/// <inheritdoc/>

if (!CaptureOptions.useAsyncReadbackIfSupported && frameCount != Time.frameCount)
Debug.LogWarning("Not on current frame: " + frameCount + "(" + Time.frameCount + ")");
if (IsVisualizationEnabled())
if (visualizationEnabled)
ReportFrameCount(frameCount);
}
asyncAnnotation.ReportValues(m_BoundingBoxValues);

/// <inheritdoc/>
protected override void SetupVisualizationPanel(GameObject panel)
protected override void PopulateVisualizationPanel(ControlPanel panel)
var toggle = GameObject.Instantiate(Resources.Load<GameObject>("GenericToggle"));
toggle.transform.SetParent(panel.transform);
toggle.GetComponentInChildren<Text>().text = "Bounding Boxes";
toggle.GetComponent<Toggle>().onValueChanged.AddListener(enabled => {
EnableVisualization(enabled);
panel.AddToggleControl("BoundingBoxes", enabled => {
visualizationEnabled = enabled;
visualizationHolder = GameObject.Instantiate(Resources.Load<GameObject>("BoundsHolder"));
visualizationHolder.transform.SetParent(panel.transform.parent, false);
visualizationHolder = new GameObject("BoundsHolder");
canvas.AddComponent(visualizationHolder);
visualizationPanelCache = new Dictionary<string, RectTransform>();
}

{
var rectTrans = GetVisualizationPanel(box.label_name);
var rectTrans = GetVisualizationPanel(box.label_name + "_" + box.instance_id);
rectTrans.anchoredPosition = new Vector2(box.x, -box.y);
rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, box.width);
rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, box.height);

return visualizationPanelCache[label];
}
void ReportFrameCount(int frame)
{
GetHud().UpdateEntry("Frame", frame.ToString());
}
override protected void OnVisualizerEnabled(bool enabled)
override protected void OnVisualizerActiveStateChanged(bool enabled)
if (!enabled) GetHud().RemoveEntry("Frame");
}
}
}

157
com.unity.perception/Runtime/GroundTruth/Labelers/CameraLabeler.cs


using System;
using System;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace UnityEngine.Perception.GroundTruth
{

/// Labelers should set this in their setup to define if they support realtime
/// visualization of their data.
/// </summary>
protected bool supportsVisualization = false;
/// <summary>
/// Flag holding if the realtime visualizer for the labeler in enabled. This
/// value is ignored if <see cref="supportsVisualization"/> is false.
/// </summary>
private bool visualizationEnabled = false;
protected abstract bool supportsVisualization
{
get;
}
/// <summary>
/// Static counter shared by all lableler classes. If any visualizers are
/// active then perception camera cannot operate in asynchronous mode.

private static VisualizationCanvas m_Canvas = null;
/// <summary>
/// Retrieve a handle to the visualization canvas <see cref="VisualizationCanvas". This is the specific canvas that all visualization
/// labelers should be added to. The canvas has helper functions to create many common visualization components.
/// </summary>
public VisualizationCanvas canvas
{
get
{
if (m_Canvas == null)
{
m_Canvas = GameObject.Instantiate(Resources.Load<GameObject>("VisualizationUI")).GetComponent<VisualizationCanvas>();
};
return m_Canvas;
}
}
/// <summary>
/// The control panel that is attached to the visualization canvas. The common location to add interactive controls.
/// </summary>
public ControlPanel controlPanel
{
get
{
return canvas.controlPanel;
}
}
/// <summary>
/// The heads up display (HUD) panel. Generally used to add stats to the display.
/// </summary>
public HUDPanel hudPanel
{
get
{
return canvas.hudPanel;
}
}
/// <summary>
/// The <see cref="PerceptionCamera"/> that contains this labeler.
/// </summary>

/// Called immediately after <see cref="setup"/>. Implement this to initialize labeler's visualization
/// capability if one exists <see cref="supportVisualization"/>.
/// </summary>
protected virtual void SetupVisualizationPanel(GameObject panel) { }
protected virtual void PopulateVisualizationPanel(ControlPanel panel) { }
protected virtual void OnVisualizerEnabled(bool enabled) {}
protected virtual void OnVisualizerActiveStateChanged(bool enabled) {}
/// <summary>
/// Called during the Update each frame the the labeler is enabled and <see cref="SensorHandle.ShouldCaptureThisFrame"/> is true.
/// </summary>

protected virtual void Cleanup() {}
internal void InternalSetup() => Setup();
internal void InternalSetupVisualizationPanel(GameObject panel) => SetupVisualizationPanel(panel);
internal void InternalVisualizerEnabled(bool enabled) => OnVisualizerEnabled(enabled);
internal void InternalPopulateVisualizationPanel(GameObject panel) => PopulateVisualizationPanel(controlPanel);
internal void InternalVisualizerActiveStateChanged(bool enabled) => OnVisualizerActiveStateChanged(enabled);
private bool m_VisualizationEnabled = true;
protected void EnableVisualization(bool enabled)
protected bool visualizationEnabled
if (!supportsVisualization) return;
get
{
return supportsVisualization && m_VisualizationEnabled;
}
set
{
if (!supportsVisualization) return;
if (enabled != visualizationEnabled)
{
visualizationEnabled = enabled;
if (enabled)
activeVisualizers++;
else
activeVisualizers--;
if (value != m_VisualizationEnabled)
{
m_VisualizationEnabled = value;
if (m_VisualizationEnabled)
activeVisualizers++;
else
activeVisualizers--;
if (activeVisualizers > 0)
CaptureOptions.useAsyncReadbackIfSupported = false;
else
CaptureOptions.useAsyncReadbackIfSupported = true;
if (activeVisualizers > 0)
CaptureOptions.useAsyncReadbackIfSupported = false;
else
CaptureOptions.useAsyncReadbackIfSupported = true;
OnVisualizerEnabled(enabled);
OnVisualizerActiveStateChanged(m_VisualizationEnabled);
}
/// <summary>
/// Is the visualization capability of the labeler currently active.
/// </summary>
protected bool IsVisualizationEnabled()
{
return supportsVisualization && visualizationEnabled;
}
internal void Init(PerceptionCamera newPerceptionCamera)
{
try

if (supportsVisualization)
{
InitPanel();
InitVisualizationUI();
}
}
catch (Exception)

}
}
private GameObject GetCanvas()
{
var canvas = GameObject.Find("Canvas");
if (canvas == null)
{
canvas = GameObject.Instantiate(Resources.Load<GameObject>("Canvas"));
canvas.name = "Canvas";
}
return canvas;
}
internal void InitPanel()
private void InitVisualizationUI()
var canvas = GetCanvas();
var panel = canvas.transform.Find("VisualizationPanel");
if (panel == null)
{
panel = GameObject.Instantiate(Resources.Load<GameObject>("VisualizationPanel")).transform;
panel.name = "VisualizationPanel";
(panel as RectTransform).SetParent(canvas.transform, false);
}
SetupVisualizationPanel(panel.gameObject);
}
internal HUDPanel GetHud()
{
var canvas = GetCanvas();
var hud = canvas.transform.Find("HUDPanel");
if (hud == null)
{
hud = GameObject.Instantiate(Resources.Load<GameObject>("HUDPanel")).transform;
hud.name = "HUDPanel";
(hud as RectTransform).SetParent(canvas.transform, false);
}
return hud.GetComponent<HUDPanel>();
PopulateVisualizationPanel(controlPanel);
}
}
}

27
com.unity.perception/Runtime/GroundTruth/Labelers/ObjectCountLabeler.cs


Dictionary<int, AsyncMetric> m_ObjectCountAsyncMetrics;
MetricDefinition m_ObjectCountMetricDefinition;
HUDPanel hud = null;
Dictionary<string, string> entryToLabelMap = null;
/// <summary>

}
/// <inheritdoc/>
protected override bool supportsVisualization => true;
/// <inheritdoc/>
protected override void Setup()
{
if (labelConfig == null)

ProduceObjectCountMetric(objectCounts, m_LabelConfig.labelEntries, frameCount);
};
supportsVisualization = true;
EnableVisualization(supportsVisualization);
visualizationEnabled = supportsVisualization;
}
/// <inheritdoc/>

count = counts[i]
};
if (IsVisualizationEnabled() && hud != null)
if (visualizationEnabled)
hud.UpdateEntry(entryToLabelMap[entries[i].label], counts[i].ToString());
hudPanel.UpdateEntry(entryToLabelMap[entries[i].label], counts[i].ToString());
}
}

/// <inheritdoc/>
protected override void SetupVisualizationPanel(GameObject panel)
protected override void PopulateVisualizationPanel(ControlPanel panel)
var toggle = GameObject.Instantiate(Resources.Load<GameObject>("GenericToggle"));
toggle.transform.SetParent(panel.transform);
toggle.GetComponentInChildren<Text>().text = "Object Counts";
toggle.GetComponent<Toggle>().onValueChanged.AddListener(enabled => {
EnableVisualization(enabled);
});
hud = GetHud();
panel.AddToggleControl("Object Counts", enabled => { visualizationEnabled = enabled; });
override protected void OnVisualizerEnabled(bool enabled)
override protected void OnVisualizerActiveStateChanged(bool enabled)
GetHud().RemoveEntry(e.Value);
hudPanel.RemoveEntry(e.Value);
}
entryToLabelMap.Clear();
}

31
com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs


Dictionary<int, AsyncMetric> m_ObjectInfoAsyncMetrics;
MetricDefinition m_RenderedObjectInfoMetricDefinition;
private HUDPanel hud = null;
Dictionary<string, string> entryToLabelMap = null;
/// <summary>

}
/// <inheritdoc/>
protected override bool supportsVisualization => true;
/// <inheritdoc/>
protected override void Setup()
{
if (idLabelConfig == null)

ProduceRenderedObjectInfoMetric(objectInfo, frameCount);
};
supportsVisualization = true;
EnableVisualization(supportsVisualization);
visualizationEnabled = supportsVisualization;
}
/// <inheritdoc/>

visible_pixels = objectInfo.pixelCount
};
if (IsVisualizationEnabled() && hud != null)
if (visualizationEnabled)
if (!entryToLabelMap.ContainsKey(labelEntry.label)) entryToLabelMap[labelEntry.label] = labelEntry.label + " Pixels";
var label = labelEntry.label + "_" + objectInfo.instanceId;
if (!entryToLabelMap.ContainsKey(label)) entryToLabelMap[label] = label + " Pixels";
hud.UpdateEntry(entryToLabelMap[labelEntry.label], objectInfo.pixelCount.ToString());
hudPanel.UpdateEntry(entryToLabelMap[label], objectInfo.pixelCount.ToString());
}
}

}
/// <inheritdoc/>
protected override void SetupVisualizationPanel(GameObject panel)
protected override void PopulateVisualizationPanel(ControlPanel panel)
var toggle = GameObject.Instantiate(Resources.Load<GameObject>("GenericToggle"));
toggle.transform.SetParent(panel.transform);
toggle.GetComponentInChildren<Text>().text = "Pixel Counts";
toggle.GetComponent<Toggle>().onValueChanged.AddListener(enabled => {
EnableVisualization(enabled);
});
hud = GetHud();
panel.AddToggleControl("Pixel Counts", enabled => { visualizationEnabled = enabled; });
override protected void OnVisualizerEnabled(bool enabled)
override protected void OnVisualizerActiveStateChanged(bool enabled)
GetHud().RemoveEntry(e.Value);
hudPanel.RemoveEntry(e.Value);
}
entryToLabelMap.Clear();
}

2
com.unity.perception/Runtime/GroundTruth/Labelers/Resources.meta


fileFormatVersion: 2
guid: 5bc1ed2485ec146ea8bebe06f70d272b
guid: 3be4f06c14c9249b1889791b25cb15f4
folderAsset: yes
DefaultImporter:
externalObjects: {}

41
com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs


using System;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;

/// the camera resolution.
/// </summary>
public RenderTexture targetTexture => m_TargetTextureOverride;
[Tooltip("(Optional) The RenderTexture on which semantic segmentation images will be drawn. Will be reformatted on startup.")]
[SerializeField]
RenderTexture m_TargetTextureOverride;

private GameObject segVisual = null;
private Image segImage = null;
/// <inheritdoc/>
protected override bool supportsVisualization => true;
/// <inheritdoc/>
protected override void Setup()

m_SemanticSegmentationTextureReader = new RenderTextureReader<Color32>(targetTexture, myCamera,
(frameCount, data, tex) => OnSemanticSegmentationImageRead(frameCount, data));
supportsVisualization = true;
EnableVisualization(supportsVisualization);
visualizationEnabled = supportsVisualization;
}
void OnSemanticSegmentationImageRead(int frameCount, NativeArray<Color32> data)

var asyncRequest = Manager.Instance.CreateRequest<AsyncRequest<AsyncSemanticSegmentationWrite>>();
if (IsVisualizationEnabled())
if (visualizationEnabled)
VisualizeSegmentationTexture(data, targetTexture);
imageReadback?.Invoke(new ImageReadbackEventArgs

}
/// <inheritdoc/>
protected override void SetupVisualizationPanel(GameObject panel)
protected override void PopulateVisualizationPanel(ControlPanel panel)
var toggle = GameObject.Instantiate(Resources.Load<GameObject>("GenericToggle"));
toggle.transform.SetParent(panel.transform);
toggle.GetComponentInChildren<Text>().text = "Segmentation Information";
toggle.GetComponent<Toggle>().onValueChanged.AddListener(enabled => {
EnableVisualization(enabled);
});
panel.AddToggleControl("Segmentation Information", enabled => { visualizationEnabled = enabled; });
var slider = GameObject.Instantiate(Resources.Load<GameObject>("GenericSlider"));
slider.transform.SetParent(panel.transform);
slider.GetComponentInChildren<Text>().text = "Object Alpha";
slider.GetComponentInChildren<Slider>().value = defaultSegmentTransparency;
slider.GetComponentInChildren<Slider>().onValueChanged.AddListener(val => {
panel.AddSliderControl("Object Alpha", defaultSegmentTransparency, val => {
slider = GameObject.Instantiate(Resources.Load<GameObject>("GenericSlider"));
slider.transform.SetParent(panel.transform);
slider.GetComponentInChildren<Text>().text = "Background Alpha";
slider.GetComponentInChildren<Slider>().value = defaultBackgroundTransparency;
slider.GetComponentInChildren<Slider>().onValueChanged.AddListener(val => {
panel.AddSliderControl("Background Alpha", defaultBackgroundTransparency, val => {
segVisual.transform.SetParent(panel.transform.parent, false);
// It is important that segment visualizer be the lowest layer part of the UI when rendered (so other annotations
// will be drawn on top of it)
segVisual.transform.SetAsFirstSibling();
segImage = segVisual.GetComponent<Image>();
segImage.material.SetFloat("_SegmentTransparency", defaultSegmentTransparency);

rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, camWidth);
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, camHeight);
canvas.AddComponent(segVisual, setAsLowestElement: true);
}
void VisualizeSegmentationTexture(NativeArray<Color32> data, RenderTexture texture)

}
/// <inheritdoc/>
override protected void OnVisualizerEnabled(bool enabled)
override protected void OnVisualizerActiveStateChanged(bool enabled)
{
if (segVisual != null)
segVisual.SetActive(enabled);

6
com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs


this.m_CameraRenderingToSource = cameraRenderingToSource;
m_NextFrameToCapture = Time.frameCount;
m_CpuTexture = new Texture2D(m_Source.width, m_Source.height, m_Source.graphicsFormat, TextureCreationFlags.None);
RenderPipelineManager.endFrameRendering += OnEndFrameRendering;
}

if (!GraphicsUtilities.SupportsAsyncReadback())
{
RenderTexture.active = m_Source;
if (m_CpuTexture == null)
m_CpuTexture = new Texture2D(m_Source.width, m_Source.height, m_Source.graphicsFormat, TextureCreationFlags.None);
m_CpuTexture.ReadPixels(new Rect(
Vector2.zero,
new Vector2(m_Source.width, m_Source.height)),

2
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat


- _QueueOffset: 0
- _ReceiveShadows: 1
- _SampleGI: 0
- _SegmentTransparency: 0.626
- _SegmentTransparency: 0.8
- _Shininess: 0
- _Smoothness: 0.5
- _SmoothnessSource: 0

2
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/KeyValuePanel.prefab


m_Script: {fileID: 11500000, guid: 8ffbc2d71e7b74cdc803e4d76cff5db4, type: 3}
m_Name:
m_EditorClassIdentifier:
key: {fileID: 1894703116479988963}
value: {fileID: 6034931589588613035}

8
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization.meta


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

128
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/ControlPanel.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
/// The control panel for labeler visualizers. This panel resides in the upper right hand corner of
/// the display. Any UI element can be added to the panel, but it contains helper methods to quickly
/// create some of the most common control panel display elements: toggles and sliders.
/// </summary>
public class ControlPanel : MonoBehaviour
{
Dictionary<string, GameObject> controlMap = new Dictionary<string, GameObject>();
/// <summary>
/// Adds a new UI control to the control panel. If the panel already contains an elment with the
/// passed in name, the UI element will not be added and the method will return false. Also, all
/// UI elements must have a LayoutElement component and if they do not, this method will reject
/// the new element, and return false.
/// </summary>
public bool AddNewControl(string name, GameObject uiControl)
{
if (uiControl.GetComponent<RectTransform>() == null)
{
Debug.LogError("Control panel UI control must have a rect transform component.");
return false;
}
if (uiControl.GetComponent<LayoutElement>() == null)
{
Debug.LogError("Control panel UI control must contain a layout element component.");
return false;
}
if (controlMap.ContainsKey(name))
{
Debug.LogWarning("A control with the name: " + name + " has already been registered with the control panel.");
return false;
}
controlMap[name] = uiControl;
uiControl.transform.SetParent(this.transform, false);
return true;
}
/// <summary>
/// Removes the component with the passed in name from the control panel. Returns
/// false if the element does not exist. Returns true on a successful removal.
/// </summary>
public bool RemoveControl(string name)
{
if (!controlMap.ContainsKey(name))
{
Debug.LogWarning(name + " does not exist in control panel, cannot remove.");
return false;
}
var control = controlMap[name];
controlMap.Remove(name);
control.transform.SetParent(null);
GameObject.Destroy(control.gameObject);
return true;
}
/// <summary>
/// Creates a new toogle control with passed in name. The passed in listener will be
/// called on toggle clicks. If anything goes wrong this method will return null.
/// Returns the control panel elemet upon a succssful add.
/// </summary>
public GameObject AddToggleControl(string name, UnityAction<bool> listener)
{
if (controlMap.ContainsKey(name))
{
Debug.LogWarning("A control with the name: " + name + " has already been registered with the control panel.");
return null;
}
if (listener == null)
{
Debug.LogWarning("Adding toggle to control panel without a listener, nothing will respond to user's clicks");
}
var toggle = GameObject.Instantiate(Resources.Load<GameObject>("GenericToggle"));
toggle.transform.SetParent(this.transform, false);
toggle.GetComponentInChildren<Text>().text = name;
toggle.GetComponent<Toggle>().onValueChanged.AddListener(listener);
controlMap[name] = toggle;
return toggle;
}
/// <summary>
/// Creates a new slider control with the passed in name and default value. The passed in listener will be
/// called on slider changes. If anything goes wrong this method will return null.
/// Returns the control panel elemet upon a succssful add.
/// </summary>
public GameObject AddSliderControl(string name, float defaultValue, UnityAction<float> listener)
{
if (controlMap.ContainsKey(name))
{
Debug.LogWarning("A control with the name: " + name + " has already been registered with the control panel.");
return null;
}
if (listener == null)
{
Debug.LogWarning("Adding slider to control panel without a listener, nothing will respond to user's interactions");
}
var gameObject = GameObject.Instantiate(Resources.Load<GameObject>("GenericSlider"));
gameObject.transform.SetParent(this.transform, false);
gameObject.GetComponentInChildren<Text>().text = name;
var slider = gameObject.GetComponentInChildren<Slider>();
slider.value = defaultValue;
slider.onValueChanged.AddListener(listener);
controlMap[name] = gameObject;
return gameObject;
}
}
}

11
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/ControlPanel.cs.meta


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

33
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/KeyValuePanel.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
///
/// </summary>
public class KeyValuePanel : MonoBehaviour
{
public Text key = null;
public Text value = null;
/// <summary>
/// Sets the key of this key value pair
/// </summary>
public void SetKey(string k)
{
if (k == null || k == string.Empty) return;
key.text = k;
}
/// <summary>
/// Sets the value of this key value pair
/// </summary>
public void SetValue(string v)
{
value.text = v;
}
}
}

8
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials.meta


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

8
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat.meta


fileFormatVersion: 2
guid: f81ae556e923c4b1d9a6047faeaa99aa
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources.meta


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

450
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/VisualizationUI.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &823664980992618516
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 823664980992618523}
- component: {fileID: 823664980992618527}
- component: {fileID: 823664980992618520}
- component: {fileID: 823664980992618521}
- component: {fileID: 823664980992618522}
- component: {fileID: 1952658930196979927}
m_Layer: 5
m_Name: HUDPanel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &823664980992618523
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 823664980992618516}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 5586713418251329534}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -10, y: 10}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 1, y: 0}
--- !u!222 &823664980992618527
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 823664980992618516}
m_CullTransparentMesh: 0
--- !u!114 &823664980992618520
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 823664980992618516}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.16470589, g: 0.16470589, b: 0.16470589, a: 0.8}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &823664980992618521
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 823664980992618516}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 20
m_Right: 20
m_Top: 10
m_Bottom: 10
m_ChildAlignment: 0
m_StartCorner: 0
m_StartAxis: 0
m_CellSize: {x: 180, y: 16}
m_Spacing: {x: 0, y: 2}
m_Constraint: 1
m_ConstraintCount: 1
--- !u!114 &823664980992618522
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 823664980992618516}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 2
--- !u!114 &1952658930196979927
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 823664980992618516}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e7683afe2bbb40e8b416440cda6edb0, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &7652432179014024090
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7652432179014024093}
- component: {fileID: 7652432179014024095}
- component: {fileID: 7652432179014024092}
m_Layer: 5
m_Name: HeaderLabel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7652432179014024093
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7652432179014024090}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.5, y: 0.5, z: 1}
m_Children: []
m_Father: {fileID: 7652432179980366449}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0.5}
--- !u!222 &7652432179014024095
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7652432179014024090}
m_CullTransparentMesh: 0
--- !u!114 &7652432179014024092
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7652432179014024090}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: 397721830eb764bbc8cd9fecf3ab1290, type: 3}
m_FontSize: 28
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 2
m_MaxSize: 40
m_Alignment: 3
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text: Visualization Options
--- !u!1 &7652432179980366462
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7652432179980366449}
- component: {fileID: 7652432179980366453}
- component: {fileID: 7652432179980366450}
- component: {fileID: 7652432179980366451}
- component: {fileID: 7652432179980366448}
- component: {fileID: 969056103226660559}
m_Layer: 5
m_Name: VisualizationPanel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7652432179980366449
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7652432179980366462}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 7652432179014024093}
m_Father: {fileID: 5586713418251329534}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -10, y: -10}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 1, y: 1}
--- !u!222 &7652432179980366453
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7652432179980366462}
m_CullTransparentMesh: 0
--- !u!114 &7652432179980366450
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7652432179980366462}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.21960784, g: 0.21960784, b: 0.21960784, a: 0.392}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &7652432179980366451
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7652432179980366462}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 10
m_Right: 10
m_Top: 5
m_Bottom: 5
m_ChildAlignment: 0
m_StartCorner: 0
m_StartAxis: 0
m_CellSize: {x: 200, y: 20}
m_Spacing: {x: 0, y: 2}
m_Constraint: 1
m_ConstraintCount: 1
--- !u!114 &7652432179980366448
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7652432179980366462}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 2
--- !u!114 &969056103226660559
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7652432179980366462}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6dbb75c37e45a4cf68053401d3cfd19d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &8560188994454015819
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5586713418251329534}
- component: {fileID: 4436340584524174639}
- component: {fileID: 3544841974704459657}
- component: {fileID: 3089939011315108982}
- component: {fileID: -8103947867589289143}
m_Layer: 5
m_Name: VisualizationUI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5586713418251329534
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8560188994454015819}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 7652432179980366449}
- {fileID: 823664980992618523}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!223 &4436340584524174639
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8560188994454015819}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!114 &3544841974704459657
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8560188994454015819}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!114 &3089939011315108982
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8560188994454015819}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &-8103947867589289143
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8560188994454015819}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 168e7de4774334a4b8c17799f9fe0699, type: 3}
m_Name:
m_EditorClassIdentifier:
controlPanel: {fileID: 969056103226660559}
hudPanel: {fileID: 1952658930196979927}

7
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/VisualizationUI.prefab.meta


fileFormatVersion: 2
guid: dd896a486440a4d0bbb12f506c4f4540
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures.meta


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

65
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/VisualizationCanvas.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
/// The visualization canvas. This canvas should contain all labeler visualization components.
/// All visualizlation components should be added to this canvas via teh AddComponent method.
/// </summary>
public class VisualizationCanvas : MonoBehaviour
{
public ControlPanel controlPanel;
public HUDPanel hudPanel;
// Start is called before the first frame update
void Start()
{
if (GameObject.Find("EventSystem") == null)
{
var eventSystemGo = new GameObject("EventSystem");
eventSystemGo.AddComponent<UnityEngine.EventSystems.EventSystem>();
eventSystemGo.AddComponent<StandaloneInputModule>();
}
}
/// <summary>
/// Adds a new UI components to the visualization canvas. Pass in fullscreen if the component should take up
/// the entire screen. Pass in setAsLowestElement if the component should be rendered behind all other components.
/// This method will return false if the element could not be added, true if everything works properly.
/// </summary>
public bool AddComponent(GameObject component, bool fullScreen = true, bool setAsLowestElement = false)
{
if (component == null)
{
Debug.LogError("Trying to add a null component to VisualizationCanvas");
return false;
}
RectTransform trans = component.GetComponent<RectTransform>();
if (trans == null)
{
Debug.LogWarning("Adding UI element without a rect transform, adding one to it");
trans = component.AddComponent<RectTransform>();
}
if (fullScreen)
{
trans.anchorMin = new Vector2(0, 0);
trans.anchorMax = new Vector2(1, 1);
trans.pivot = new Vector2(0.5f, 0.5f);
trans.offsetMax = new Vector2(0, 0);
trans.offsetMin = new Vector2(0, 0);
}
trans.SetParent(this.transform, false);
if (setAsLowestElement) component.transform.SetAsFirstSibling();
return true;
}
}
}

11
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/VisualizationCanvas.cs.meta


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

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/BoundingBoxPrefab.prefab → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/BoundingBoxPrefab.prefab

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/BoundingBoxPrefab.prefab.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/BoundingBoxPrefab.prefab.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/GenericSlider.prefab → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/GenericSlider.prefab

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/GenericSlider.prefab.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/GenericSlider.prefab.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/GenericToggle.prefab → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/GenericToggle.prefab

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/GenericToggle.prefab.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/GenericToggle.prefab.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/Inter-Light.otf → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/Inter-Light.otf

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/Inter-Light.otf.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/Inter-Light.otf.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/OutlineMaterial.mat → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/OutlineMaterial.mat

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/OutlineMaterial.mat.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/OutlineMaterial.mat.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/SegmentTexture.prefab → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegmentTexture.prefab

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/SegmentTexture.prefab.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegmentTexture.prefab.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/outline_box.png → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures/outline_box.png

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/outline_box.png.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures/outline_box.png.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/sharp_done_white_18dp.png → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures/sharp_done_white_18dp.png

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/sharp_done_white_18dp.png.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Textures/sharp_done_white_18dp.png.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/SegRemoveBackgroundShader.shader.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegRemoveBackgroundShader.shader.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/SegRemoveBackgroundShader.shader → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegRemoveBackgroundShader.shader

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/SegmentationMaterial.mat → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/HUDPanel.cs → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/HUDPanel.cs

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/HUDPanel.cs.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/HUDPanel.cs.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/KeyValuePanel.cs.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/KeyValuePanel.cs.meta

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/KeyValuePanel.prefab → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/KeyValuePanel.prefab

/com.unity.perception/Runtime/GroundTruth/Labelers/Resources/KeyValuePanel.prefab.meta → /com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/KeyValuePanel.prefab.meta

正在加载...
取消
保存