Legacy Documentation: Version 5.4
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

LineRenderer

class in UnityEngine

/

Inherits from: Renderer

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Description

The line renderer is used to draw free-floating lines in 3D space.

This class is a script interface for a line renderer component.

Variables

useWorldSpaceIf enabled, the lines are defined in world space.

Public Functions

SetColorsSet the line color at the start and at the end.
SetPositionSet the position of the vertex in the line.
SetPositionsSet the positions of all vertices in the line.
SetVertexCountSet the number of line segments.
SetWidthSet the line width at the start and at the end.

Inherited members

Variables

gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject (null if there is none attached).
hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
nameThe name of the object.
boundsThe bounding volume of the renderer (Read Only).
enabledMakes the rendered 3D object visible if enabled.
isPartOfStaticBatchHas this renderer been statically batched with any other renderers?
isVisibleIs this renderer visible in any camera? (Read Only)
lightmapIndexThe index of the baked lightmap applied to this renderer.
lightmapScaleOffsetThe UV scale & offset used for a lightmap.
lightProbeProxyVolumeOverrideIf set, the Renderer will use the Light Probe Proxy Volume component attached to the source GameObject.
lightProbeUsageThe light probe interpolation type.
localToWorldMatrixMatrix that transforms a point from local space into world space (Read Only).
materialReturns the first instantiated Material assigned to the renderer.
materialsReturns all the instantiated materials of this object.
motionVectorsSpecifies whether this renderer has a per-object motion vector pass.
probeAnchorIf set, Renderer will use this Transform's position to find the light or reflection probe.
realtimeLightmapIndexThe index of the realtime lightmap applied to this renderer.
realtimeLightmapScaleOffsetThe UV scale & offset used for a realtime lightmap.
receiveShadowsDoes this object receive shadows?
reflectionProbeUsageShould reflection probes be used for this Renderer?
shadowCastingModeDoes this object cast shadows?
sharedMaterialThe shared material of this object.
sharedMaterialsAll the shared materials of this object.
sortingLayerIDUnique ID of the Renderer's sorting layer.
sortingLayerNameName of the Renderer's sorting layer.
sortingOrderRenderer's order within a sorting layer.
worldToLocalMatrixMatrix that transforms a point from world space into local space (Read Only).

Public Functions

BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagIs this game object tagged with tag ?
GetComponentReturns the component of Type type if the game object has one attached, null if it doesn't.
GetComponentInChildrenReturns the component of Type type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the component of Type type in the GameObject or any of its parents.
GetComponentsReturns all components of Type type in the GameObject.
GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children.
GetComponentsInParentReturns all components of Type type in the GameObject or any of its parents.
SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the game object.
GetClosestReflectionProbesReturns an array of closest reflection probes with weights, weight shows how much influence the probe has on the renderer, this value is also used when blending between reflection probes occur.
GetPropertyBlockGet per-renderer material property block.
SetPropertyBlockLets you add per-renderer material parameters without duplicating a material.

Static Functions

DestroyRemoves a gameobject, component or asset.
DestroyImmediateDestroys the object obj immediately.
DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
InstantiateReturns a copy of the object original.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.

Messages

OnBecameInvisible OnBecameInvisible is called when the object is no longer visible by any camera.
OnBecameVisible OnBecameVisible is called when the object became visible by any camera.