Version: 2019.2
LanguageEnglish
  • C#

TrailRenderer

class in UnityEngine

/

Inherits from:Renderer

/

Implemented in:UnityEngine.CoreModule

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

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> 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 trail renderer is used to make trails behind objects in the Scene as they move about.

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

Properties

alignmentSelect whether the trail will face the camera, or the orientation of the Transform Component.
autodestructDoes the GameObject of this Trail Renderer auto destruct?
colorGradientSet the color gradient describing the color of the trail at various points along its length.
emittingCreates trails when the GameObject moves.
endColorSet the color at the end of the trail.
endWidthThe width of the trail at the end of the trail.
generateLightingDataConfigures a trail to generate Normals and Tangents. With this data, Scene lighting can affect the trail via Normal Maps and the Unity Standard Shader, or your own custom-built Shaders.
minVertexDistanceSet the minimum distance the trail can travel before a new vertex is added to it.
numCapVerticesSet this to a value greater than 0, to get rounded corners on each end of the trail.
numCornerVerticesSet this to a value greater than 0, to get rounded corners between each segment of the trail.
positionCountGet the number of line segments in the trail.
shadowBiasApply a shadow bias to prevent self-shadowing artifacts. The specified value is the proportion of the trail width at each segment.
startColorSet the color at the start of the trail.
startWidthThe width of the trail at the spawning point.
textureModeChoose whether the U coordinate of the trail texture is tiled or stretched.
timeHow long does the trail take to fade out.
widthCurveSet the curve describing the width of the trail at various points along its length.
widthMultiplierSet an overall multiplier that is applied to the TrailRenderer.widthCurve to get the final width of the trail.

Public Methods

AddPositionAdds a position to the trail.
AddPositionsAdd an array of positions to the trail.
BakeMeshCreates a snapshot of TrailRenderer and stores it in mesh.
ClearRemoves all points from the TrailRenderer. Useful for restarting a trail from a new position.
GetPositionGet the position of a vertex in the trail.
GetPositionsGet the positions of all vertices in the trail.
SetPositionSet the position of a vertex in the trail.
SetPositionsSets the positions of all vertices in the trail.

Inherited Members

Properties

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.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.
allowOcclusionWhenDynamicControls if dynamic occlusion culling should be performed for this renderer.
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.
motionVectorGenerationModeSpecifies the mode for motion vector rendering.
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?
rendererPriorityThis value sorts renderers by priority. Lower values are rendered first and higher values are rendered last.
renderingLayerMaskDetermines which rendering layer this renderer lives on.
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 Methods

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.
TryGetComponentGets the component of the specified type, if it exists.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the 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.
GetMaterialsReturns all the instantiated materials of this object.
GetPropertyBlockGet per-Renderer or per-Material property block.
GetSharedMaterialsReturns all the shared materials of this object.
HasPropertyBlockReturns true if the Renderer has a material property block attached via SetPropertyBlock.
SetPropertyBlockLets you set or clear per-renderer or per-material parameter overrides.

Static Methods

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object 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.
InstantiateClones the object original and returns the clone.

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.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961