Skip to content
5 changes: 5 additions & 0 deletions com.unity.robotics.visualizations/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

### Fixed

## [0.7.2-preview] - 2022-07-11

Added a Visualization Layer property to DrawingManager3d to allow developers to specify which layer the visualizations render into.
Defaults to UI layer, and the sensors in sensors package will set the culling mask to not sense the UI layer. If you add a new layer
and choose that (or another builtin layer), you should deselect that layer in the culling mask of any sensors that have a camera component.

## [0.7.0-preview] - 2022-02-01

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public static Drawing3dManager instance
List<Drawing3d> m_Drawings = new List<Drawing3d>();
List<Drawing3d> m_Dirty = new List<Drawing3d>();

[SerializeField]
DrawingLayer m_VisualizationLayer = new DrawingLayer();

public int VisualizationLayer => m_VisualizationLayer.LayerNumber;

[SerializeField]
Material m_UnlitVertexColorMaterial;
[SerializeField]
Expand Down Expand Up @@ -68,6 +73,7 @@ public void DestroyDrawing(Drawing3d drawing)
public static Drawing3d CreateDrawing(float duration = -1, Material material = null)
{
GameObject newDrawingObj = new GameObject("Drawing");
newDrawingObj.layer = Drawing3dManager.instance.VisualizationLayer;
Drawing3d newDrawing = newDrawingObj.AddComponent<Drawing3d>();
newDrawing.Init(instance, material != null ? material : instance.UnlitVertexColorMaterial, duration);
instance.m_Drawings.Add(newDrawing);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace Unity.Robotics.Visualizations
{
[Serializable]
public class DrawingLayer
{
public int LayerNumber = 5; // Default to builtin UI layer
}

#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(DrawingLayer))]
public class DrawingLayerPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, GUIContent.none, property);
SerializedProperty layer = property.FindPropertyRelative("LayerNumber");
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
if (layer != null)
layer.intValue = EditorGUI.LayerField(position, layer.intValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Though you really shouldn't have to go to this much trouble, there should be a SelectableLayer struct predefined in the engine...

EditorGUI.EndProperty();
}
}
#endif
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static PointCloudDrawing Create(GameObject parent = null, int numPoints =
newDrawingObj.transform.parent = parent.transform;
newDrawingObj.transform.localPosition = Vector3.zero;
newDrawingObj.transform.localRotation = Quaternion.identity;
newDrawingObj.layer = Drawing3dManager.instance.VisualizationLayer;
}
PointCloudDrawing newDrawing = newDrawingObj.AddComponent<PointCloudDrawing>();
newDrawing.SetCapacity(numPoints);
Expand Down