Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


DrawOutline

Draws an outline around the specified GameObjects in the Scene View.
Read time 18 minutesLast updated 10 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

DrawOutline(int[], int[], Color, Color, float)

Draws an outline around the specified GameObjects in the Scene View.
Warning
Removed. Deprecated. Use DrawOutline(EntityId[], EntityId[], Color, Color, float) instead.
public static void DrawOutline(int[] parentRenderers, int[] childRenderers, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)

Parameters

parentRenderers

The instance IDs of the first set of Renderers. If you provide GameObjects or Renderers as parameters, these Renderers belong to the GameObjects provided explicitly in the parameters.

childRenderers

The instance IDs of the second set of Renderers. If you provide GameObjects or Renderers as parameters, these Renderers belong to the child GameObjects of the objects provided in the parameters.

parentNodeColor

The color of the outline of the GameObjects provided explicitly in the
objects
parameter and the
parentRenderers
parameters. The alpha value controls the intensity of the outline.

childNodeColor

The color of the outline of the GameObjects which are children to the GameObjects in the
objects
parameter. The alpha value controls the intensity of the outline.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}

DrawOutline(EntityId[], EntityId[], Color, Color, float)

Draws an outline around the specified GameObjects in the Scene View.
public static void DrawOutline(EntityId[] parentRenderers, EntityId[] childRenderers, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)

Parameters

parentRenderers

The instance IDs of the first set of Renderers. If you provide GameObjects or Renderers as parameters, these Renderers belong to the GameObjects provided explicitly in the parameters.

childRenderers

The instance IDs of the second set of Renderers. If you provide GameObjects or Renderers as parameters, these Renderers belong to the child GameObjects of the objects provided in the parameters.

parentNodeColor

The color of the outline of the GameObjects provided explicitly in the
objects
parameter and the
parentRenderers
parameters. The alpha value controls the intensity of the outline.

childNodeColor

The color of the outline of the GameObjects which are children to the GameObjects in the
objects
parameter. The alpha value controls the intensity of the outline.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}

DrawOutline(int[], Color, float)

Draws an outline around the specified GameObjects in the Scene View.
Warning
Removed. Deprecated. Use DrawOutline(EntityId[], Color, float) instead.
public static void DrawOutline(int[] renderers, Color color, float fillOpacity = 0)

Parameters

renderers

The Renderers to outline.

color

The color of the outline for the
objects
and
renderers
.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}

DrawOutline(EntityId[], Color, float)

Draws an outline around the specified GameObjects in the Scene View.
public static void DrawOutline(EntityId[] renderers, Color color, float fillOpacity = 0)

Parameters

renderers

The Renderers to outline.

color

The color of the outline for the
objects
and
renderers
.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}

DrawOutline(Renderer[], Color, Color, float)

Draws an outline around the specified GameObjects in the Scene View.
public static void DrawOutline(Renderer[] renderers, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)

Parameters

renderers

The Renderers to outline.

parentNodeColor

The color of the outline of the GameObjects provided explicitly in the
objects
parameter and the
parentRenderers
parameters. The alpha value controls the intensity of the outline.

childNodeColor

The color of the outline of the GameObjects which are children to the GameObjects in the
objects
parameter. The alpha value controls the intensity of the outline.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}

DrawOutline(Renderer[], Color, float)

Draws an outline around the specified GameObjects in the Scene View.
public static void DrawOutline(Renderer[] renderers, Color color, float fillOpacity = 0)

Parameters

renderers

The Renderers to outline.

color

The color of the outline for the
objects
and
renderers
.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}

DrawOutline(GameObject[], Color, Color, float)

Draws an outline around the specified GameObjects in the Scene View.
public static void DrawOutline(GameObject[] objects, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)

Parameters

The GameObjects to outline.

parentNodeColor

The color of the outline of the GameObjects provided explicitly in the
objects
parameter and the
parentRenderers
parameters. The alpha value controls the intensity of the outline.

childNodeColor

The color of the outline of the GameObjects which are children to the GameObjects in the
objects
parameter. The alpha value controls the intensity of the outline.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}

DrawOutline(GameObject[], Color, float)

Draws an outline around the specified GameObjects in the Scene View.
public static void DrawOutline(GameObject[] objects, Color color, float fillOpacity = 0)

Parameters

The GameObjects to outline.

color

The color of the outline for the
objects
and
renderers
.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}

DrawOutline(List<GameObject>, Color, Color, float)

Draws an outline around the specified GameObjects in the Scene View.
public static void DrawOutline(List<GameObject> objects, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)

Parameters

The GameObjects to outline.

parentNodeColor

The color of the outline of the GameObjects provided explicitly in the
objects
parameter and the
parentRenderers
parameters. The alpha value controls the intensity of the outline.

childNodeColor

The color of the outline of the GameObjects which are children to the GameObjects in the
objects
parameter. The alpha value controls the intensity of the outline.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}

DrawOutline(List<GameObject>, Color, float)

Draws an outline around the specified GameObjects in the Scene View.
public static void DrawOutline(List<GameObject> objects, Color color, float fillOpacity = 0)

Parameters

The GameObjects to outline.

color

The color of the outline for the
objects
and
renderers
.

fillOpacity

The opacity of the Renderers within each outline.

Remarks

This only applies to GameObjects that have Renderer components. You can only use this during a EventType.Repaint event.
Instead of passing in GameObjects or Renderers, you can also use Renderer instance IDs. This improves performance because Unity doesn't need to get the instance IDs from the GameObjects or Renderers every time you call this function.
NOTE: Overloads that take GameObject[], Renderer[] or List\<GameObject\> as arguments are there for convenience, using them might result in additional allocations that cause additional garbage collection. To avoid performance or memory issues, use these overloads only when drawing a relatively small number of outlines (consider providing renderer instance IDs directly if the number of outlines exceeds 100).
The alpha values of
parentNodeColor
and
childNodeColor
control the intensity of the outline, 0 makes it completely transparent and 1 makes it fully opaque.
The
fillOpacity
controls the weight of the color multiplier for the Renderer. Higher
fillOpacity
values make the color more intense and leave the original object less visible.
Additional Resources: Handles.DrawCamera.

Examples

using UnityEditor;using UnityEngine;namespace UnityEditor{ [CustomEditor(typeof(GameObject))] public class CustomInspector : Editor { private GameObject[] objects; public void OnEnable() { // Note: If you use FindGameObjectsWithTag in a Prefab Stage that you opened from a Scene, // it includes GameObjects from that Scene. Instead use: // var renderers = StageUtility.GetCurrentStage().FindComponentsOfType<Renderer>(); // to explicitly specify where to get the GameObjects from. objects = GameObject.FindGameObjectsWithTag("Player"); // populate the objects array with game objects } public void OnSceneGUI() { // draw the outline with an alpha of 0.5 if (Event.current.type == EventType.Repaint) Handles.DrawOutline(objects, Color.yellow, Color.green, 0.1f); } }}