wiki.sine.space | sinespace

Difference between revisions of "Scripting/STrailRenderer"

From wiki.sine.space
Jump to: navigation, search
m
Line 8: Line 8:
 
{{ScriptFunction|int|Alignment|{ get;set; }|Select whether the trail will face the camera, or the orientation of the Transform Component.
 
{{ScriptFunction|int|Alignment|{ get;set; }|Select whether the trail will face the camera, or the orientation of the Transform Component.
 
0 = View
 
0 = View
1 = Transform Z|5=<pre>Space.Host.ExecutingObject.TrailRenderer.Alignment = 1</pre>}}
+
1 = Transform Z|5=<pre>Space.Host.ExecutingObject.TrailRenderer.Alignment = 1</pre>|6=<pre>--Clicking the object toggles between TrailRenderer's View or Transform Z alignment
 +
--[Add "trailrenderer" reference to the Scripting Runtime component]
  
{{ScriptFunction|bool|Autodestruct|{ get;set; }|Does the GameObject of this Trail Renderer auto destruct?|5=<pre>Space.Host.ExecutingObject.TrailRenderer.Autodestruct = true
+
thisGameObject = Space.Host.ExecutingObject
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 
 +
 
 +
OnClick = function()
 +
  if trailrenderer.Alignment == 0 then
 +
    trailrenderer.Alignment = 1
 +
  else
 +
    trailrenderer.Alignment = 0
 +
  end
 +
end
 +
 
 +
 
 +
thisGameObject.AddClickable()
 +
thisGameObject.Clickable.OnClick(OnClick)
 
</pre>}}
 
</pre>}}
 +
 +
{{ScriptFunction|bool|Autodestruct|{ get;set; }|Does the GameObject of this Trail Renderer auto destruct?|5=<pre>Space.Host.ExecutingObject.TrailRenderer.Autodestruct = true
 +
</pre>|6=<pre>--Make a UIToggle disable/enable the Autodestruct feature of a Trail Renderer
 +
--[Add "toggle" and "trailrenderer" references to the Scripting Runtime component]
 +
 +
thisGameObject = Space.Host.ExecutingObject
 +
 +
toggle = Space.Host.GetReference("toggle").UIToggle
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 +
toggle.IsOn = trailrenderer.Autodestruct  --make toggle start at correct state
 +
 +
OVC = function()
 +
  if toggle.IsOn then
 +
    trailrenderer.Autodestruct  = true
 +
  else
 +
    trailrenderer.Autodestruct  = false
 +
  end
 +
end
 +
 +
toggle.OnValueChanged(OVC)</pre>}}
  
 
{{ScriptFunction|bool|CastShadows|{ get;set; }|Does the trail cast a shadow when a shadow-casting Light shines on it?|5=<pre>Space.Host.ExecutingObject.TrailRenderer.CastShadows = true
 
{{ScriptFunction|bool|CastShadows|{ get;set; }|Does the trail cast a shadow when a shadow-casting Light shines on it?|5=<pre>Space.Host.ExecutingObject.TrailRenderer.CastShadows = true
 
</pre>}}
 
</pre>}}
  
{{ScriptFunction|bool|Enabled|{ get;set }|Whether this TrailRenderer component is Enabled or not|5=<pre>Space.Host.ExecutingObject.TrailRenderer.Enabled = true</pre>}}
+
{{ScriptFunction|bool|Enabled|{ get;set }|Whether this TrailRenderer component is Enabled or not|5=<pre>Space.Host.ExecutingObject.TrailRenderer.Enabled = true</pre>|6=<pre>--Clicking the object Enables/Disables the Trail Renderer component on this object 
 +
--[Add "trailrenderer" reference to the Scripting Runtime component]
 +
 
 +
thisGameObject = Space.Host.ExecutingObject
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 
 +
 
 +
OnClick = function()
 +
trailrenderer.Enabled =  not trailrenderer.Enabled
 +
end
 +
 
 +
 
 +
thisGameObject.AddClickable()
 +
thisGameObject.Clickable.OnClick(OnClick)</pre>}}
  
 
{{ScriptFunction|Scolor|EndColor|{ get;set; }|Set the color at the end of the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.EndColor = Color.Red</pre>}}
 
{{ScriptFunction|Scolor|EndColor|{ get;set; }|Set the color at the end of the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.EndColor = Color.Red</pre>}}
  
 
{{ScriptFunction|float|EndWidth|{ get;set; }|The width of the trail at the end of the trail.
 
{{ScriptFunction|float|EndWidth|{ get;set; }|The width of the trail at the end of the trail.
A width of 1 corresponds to 1 unit in the game world.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.EndWidth = 0.1</pre>}}
+
A width of 1 corresponds to 1 unit in the game world.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.EndWidth = 0.1</pre>|6=<pre>--Make a slider change the Trail Renderer's End Width
 +
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]
 +
 
 +
thisGameObject = Space.Host.ExecutingObject
 +
 
 +
slider = Space.Host.GetReference("slider").UISlider
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 
 +
 
 +
OVC = function()
 +
trailrenderer.EndWidth = slider.Value * 10 --0 to 10
 +
end
 +
 
 +
slider.OnValueChanged(OVC)
 +
</pre>}}
  
 
{{ScriptFunction|bool|IsVisible|{ get; }|Is this renderer visible in any camera?|5=<pre>Space.Log(Space.Host.ExecutingObject.TrailRenderer.IsVisible)</pre>}}
 
{{ScriptFunction|bool|IsVisible|{ get; }|Is this renderer visible in any camera?|5=<pre>Space.Log(Space.Host.ExecutingObject.TrailRenderer.IsVisible)</pre>}}
  
 
{{ScriptFunction|float|MinVertexDistance|{ get;set; }|Set the minimum distance the trail can travel before a new vertex is added to it.  
 
{{ScriptFunction|float|MinVertexDistance|{ get;set; }|Set the minimum distance the trail can travel before a new vertex is added to it.  
Smaller values with give smoother trails, consisting of more vertices, but costing more performance.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.MinVertexDistance = 1</pre>}}
+
Smaller values with give smoother trails, consisting of more vertices, but costing more performance.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.MinVertexDistance = 1</pre>|6=<pre>--Make a slider change the Trail Renderer's Number of Mininum Vertex Distance
 +
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]
 +
 
 +
thisGameObject = Space.Host.ExecutingObject
 +
 
 +
slider = Space.Host.GetReference("slider").UISlider
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 
 +
 
 +
OVC = function()
 +
trailrenderer.MinVertexDistance = slider.Value * 10 --0 to 10
 +
end
 +
 
 +
slider.OnValueChanged(OVC)
 +
 
 +
</pre>}}
  
 
{{ScriptFunction|bool|MotionVectors|{ get;set; }|Set whether to use motion vectors to track this Renderer’s per-pixel, screen-space motion from one frame to the next. You can use this information to apply post-processing effects such as motion blur.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.MotionVectors = true</pre>}}
 
{{ScriptFunction|bool|MotionVectors|{ get;set; }|Set whether to use motion vectors to track this Renderer’s per-pixel, screen-space motion from one frame to the next. You can use this information to apply post-processing effects such as motion blur.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.MotionVectors = true</pre>}}
  
{{ScriptFunction|int|NumCapVertices|{ get;set; }|Set this to a value greater than 0, to get rounded corners on each end of the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.NumCapVertices = 3</pre>}}
+
{{ScriptFunction|int|NumCapVertices|{ get;set; }|Set this to a value greater than 0, to get rounded corners on each end of the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.NumCapVertices = 3</pre>|6=<pre>--Make a slider change the Trail Renderer's Number of End Cap Vertices
 +
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]
  
{{ScriptFunction|int|NumCornerVertices|{ get;set; }|Set this to a value greater than 0, to get rounded corners between each segment of the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.NumCornerVertices = 2</pre>}}
+
thisGameObject = Space.Host.ExecutingObject
 +
 
 +
slider = Space.Host.GetReference("slider").UISlider
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 
 +
 
 +
OVC = function()
 +
trailrenderer.NumCapVertices = slider.Value * 90 --0 to 90
 +
end
 +
 
 +
slider.OnValueChanged(OVC)</pre>}}
 +
 
 +
{{ScriptFunction|int|NumCornerVertices|{ get;set; }|Set this to a value greater than 0, to get rounded corners between each segment of the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.NumCornerVertices = 2</pre>|6=<pre>--Make a slider change the Trail Renderer's Number of Corner Vertices
 +
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]
 +
 
 +
thisGameObject = Space.Host.ExecutingObject
 +
 
 +
slider = Space.Host.GetReference("slider").UISlider
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 
 +
 
 +
OVC = function()
 +
trailrenderer.NumCornerVertices = slider.Value * 90 --0 to 90
 +
end
 +
 
 +
slider.OnValueChanged(OVC)</pre>}}
  
 
{{ScriptFunction|int|PositionCount|{ get; }|Get the number of line segments in the trail.|5=<pre>numLineSegments = Space.Host.ExecutingObject.TrailRenderer.PositionCount</pre>}}
 
{{ScriptFunction|int|PositionCount|{ get; }|Get the number of line segments in the trail.|5=<pre>numLineSegments = Space.Host.ExecutingObject.TrailRenderer.PositionCount</pre>}}
Line 41: Line 145:
  
 
{{ScriptFunction|float|StartWidth|{ get;set; }|The width of the trail at the spawning point.
 
{{ScriptFunction|float|StartWidth|{ get;set; }|The width of the trail at the spawning point.
A width of 1 corresponds to 1 unit in the game world.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.StartWidth = 1.1</pre>}}
+
A width of 1 corresponds to 1 unit in the game world.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.StartWidth = 1.1</pre>|6=<pre>--Make a slider change the Trail Renderer's Start Width
 +
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]
 +
 
 +
thisGameObject = Space.Host.ExecutingObject
 +
 
 +
slider = Space.Host.GetReference("slider").UISlider
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 
 +
 
 +
OVC = function()
 +
trailrenderer.StartWidth = slider.Value * 10 --0 to 10
 +
end
 +
 
 +
slider.OnValueChanged(OVC)</pre>}}
  
 
{{ScriptFunction|int|TextureMode|{ get;set; }|Choose whether the U coordinate of the trail texture is tiled or stretched.
 
{{ScriptFunction|int|TextureMode|{ get;set; }|Choose whether the U coordinate of the trail texture is tiled or stretched.
 
0 Stretch, 1 Tile, 2 Distribute Per Segment, 3 Repeat Per Segment|5=<pre>Space.Host.ExecutingObject.TrailRenderer.TextureMode = 2</pre>}}
 
0 Stretch, 1 Tile, 2 Distribute Per Segment, 3 Repeat Per Segment|5=<pre>Space.Host.ExecutingObject.TrailRenderer.TextureMode = 2</pre>}}
  
{{ScriptFunction|float|Time|{ get;set; }|How long does the trail take to fade out. (seconds)|5=<pre>Space.Host.ExecutingObject.TrailRenderer.Time = 10</pre>}}
+
{{ScriptFunction|float|Time|{ get;set; }|How long does the trail take to fade out. (seconds)|5=<pre>Space.Host.ExecutingObject.TrailRenderer.Time = 10</pre>|6=<pre>--Make a slider change the Trail Renderer's Time
 +
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]
 +
 
 +
thisGameObject = Space.Host.ExecutingObject
 +
 
 +
slider = Space.Host.GetReference("slider").UISlider
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 
 +
 
 +
OVC = function()
 +
trailrenderer.Time = slider.Value * 10 --0 to 10
 +
end
 +
 
 +
slider.OnValueChanged(OVC)</pre>}}
 +
 
  
 
{{ScriptFunction|bool|UseLightProbes|{ get;set; }|Enable Light Probes on the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.UseLightProbes = true</pre>}}
 
{{ScriptFunction|bool|UseLightProbes|{ get;set; }|Enable Light Probes on the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.UseLightProbes = true</pre>}}
  
{{ScriptFunction|float|WidthMultiplier|{ get;set; }|Set an overall multiplier that is applied to the TrailRenderer.widthCurve to get the final width of the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.WidthMultiplier = 2</pre>}}
+
 
 +
{{ScriptFunction|float|WidthMultiplier|{ get;set; }|Set an overall multiplier that is applied to the TrailRenderer.widthCurve to get the final width of the trail.|5=<pre>Space.Host.ExecutingObject.TrailRenderer.WidthMultiplier = 2</pre>|6=<pre>--Make a slider change the Trail Renderer's Width Multiplier
 +
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]
 +
 
 +
thisGameObject = Space.Host.ExecutingObject
 +
 
 +
slider = Space.Host.GetReference("slider").UISlider
 +
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer
 +
 
 +
 
 +
OVC = function()
 +
trailrenderer.WidthMultiplier = slider.Value * 10 --0 to 10
 +
end
 +
 
 +
slider.OnValueChanged(OVC)</pre>}}
  
  

Revision as of 07:30, 12 October 2021

Members

Clear

void Clear ();

Removes all points from the TrailRenderer. Useful for restarting a trail from a new position.

Space.Host.ExecutingObject.TrailRenderer.Clear()


GetPosition

SVector GetPosition (int index);

Get the position of a vertex in the trail.

vectorPos = Space.Host.ExecutingObject.TrailRenderer.GetPosition(0)



Properties

Alignment

int Alignment { get;set; }

No documentation

Space.Host.ExecutingObject.TrailRenderer.Alignment = 1


--Clicking the object toggles between TrailRenderer's View or Transform Z alignment
--[Add "trailrenderer" reference to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer


OnClick = function()
  if trailrenderer.Alignment == 0 then
    trailrenderer.Alignment = 1
  else
    trailrenderer.Alignment = 0
  end
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

Autodestruct

bool Autodestruct { get;set; }

Does the GameObject of this Trail Renderer auto destruct?

Space.Host.ExecutingObject.TrailRenderer.Autodestruct = true


--Make a UIToggle disable/enable the Autodestruct feature of a Trail Renderer
--[Add "toggle" and "trailrenderer" references to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject

toggle = Space.Host.GetReference("toggle").UIToggle 
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer

toggle.IsOn = trailrenderer.Autodestruct  --make toggle start at correct state

OVC = function()
  if toggle.IsOn then
    trailrenderer.Autodestruct  = true
  else
    trailrenderer.Autodestruct  = false
  end
end

toggle.OnValueChanged(OVC)

CastShadows

bool CastShadows { get;set; }

Does the trail cast a shadow when a shadow-casting Light shines on it?

Space.Host.ExecutingObject.TrailRenderer.CastShadows = true


Enabled

bool Enabled { get;set }

Whether this TrailRenderer component is Enabled or not

Space.Host.ExecutingObject.TrailRenderer.Enabled = true


--Clicking the object Enables/Disables the Trail Renderer component on this object  
--[Add "trailrenderer" reference to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer


OnClick = function()
trailrenderer.Enabled =  not trailrenderer.Enabled
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

EndColor

Scolor EndColor { get;set; }

Set the color at the end of the trail.

Space.Host.ExecutingObject.TrailRenderer.EndColor = Color.Red


EndWidth

float EndWidth { get;set; }

The width of the trail at the end of the trail. A width of 1 corresponds to 1 unit in the game world.

Space.Host.ExecutingObject.TrailRenderer.EndWidth = 0.1


--Make a slider change the Trail Renderer's End Width
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject

slider = Space.Host.GetReference("slider").UISlider
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer


OVC = function()
trailrenderer.EndWidth = slider.Value * 10 --0 to 10
end

slider.OnValueChanged(OVC)

IsVisible

bool IsVisible { get; }

Is this renderer visible in any camera?

Space.Log(Space.Host.ExecutingObject.TrailRenderer.IsVisible)


MinVertexDistance

float MinVertexDistance { get;set; }

Set the minimum distance the trail can travel before a new vertex is added to it. Smaller values with give smoother trails, consisting of more vertices, but costing more performance.

Space.Host.ExecutingObject.TrailRenderer.MinVertexDistance = 1


--Make a slider change the Trail Renderer's Number of Mininum Vertex Distance
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject

slider = Space.Host.GetReference("slider").UISlider
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer


OVC = function()
trailrenderer.MinVertexDistance = slider.Value * 10 --0 to 10
end

slider.OnValueChanged(OVC)

MotionVectors

bool MotionVectors { get;set; }

Set whether to use motion vectors to track this Renderer’s per-pixel, screen-space motion from one frame to the next. You can use this information to apply post-processing effects such as motion blur.

Space.Host.ExecutingObject.TrailRenderer.MotionVectors = true


NumCapVertices

int NumCapVertices { get;set; }

Set this to a value greater than 0, to get rounded corners on each end of the trail.

Space.Host.ExecutingObject.TrailRenderer.NumCapVertices = 3


--Make a slider change the Trail Renderer's Number of End Cap Vertices
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject

slider = Space.Host.GetReference("slider").UISlider
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer


OVC = function()
trailrenderer.NumCapVertices = slider.Value * 90 --0 to 90
end

slider.OnValueChanged(OVC)

NumCornerVertices

int NumCornerVertices { get;set; }

Set this to a value greater than 0, to get rounded corners between each segment of the trail.

Space.Host.ExecutingObject.TrailRenderer.NumCornerVertices = 2


--Make a slider change the Trail Renderer's Number of Corner Vertices
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject

slider = Space.Host.GetReference("slider").UISlider
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer


OVC = function()
trailrenderer.NumCornerVertices = slider.Value * 90 --0 to 90
end

slider.OnValueChanged(OVC)

PositionCount

int PositionCount { get; }

Get the number of line segments in the trail.

numLineSegments = Space.Host.ExecutingObject.TrailRenderer.PositionCount


ReceiveShadows

bool ReceiveShadows { get;set; }

Does this object receive shadows?

Space.Host.ExecutingObject.TrailRenderer.ReceiveShadows = true


StartColor

SColor StartColor { get;set; }

Set the color at the start of the trail.

Space.Host.ExecutingObject.TrailRenderer.StartColor = Color.Black


StartWidth

float StartWidth { get;set; }

The width of the trail at the spawning point. A width of 1 corresponds to 1 unit in the game world.

Space.Host.ExecutingObject.TrailRenderer.StartWidth = 1.1


--Make a slider change the Trail Renderer's Start Width
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject

slider = Space.Host.GetReference("slider").UISlider
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer


OVC = function()
trailrenderer.StartWidth = slider.Value * 10 --0 to 10
end

slider.OnValueChanged(OVC)

TextureMode

int TextureMode { get;set; }

Choose whether the U coordinate of the trail texture is tiled or stretched. 0 Stretch, 1 Tile, 2 Distribute Per Segment, 3 Repeat Per Segment

Space.Host.ExecutingObject.TrailRenderer.TextureMode = 2


Time

float Time { get;set; }

How long does the trail take to fade out. (seconds)

Space.Host.ExecutingObject.TrailRenderer.Time = 10


--Make a slider change the Trail Renderer's Time
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject

slider = Space.Host.GetReference("slider").UISlider
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer


OVC = function()
trailrenderer.Time = slider.Value * 10 --0 to 10
end

slider.OnValueChanged(OVC)


UseLightProbes

bool UseLightProbes { get;set; }

Enable Light Probes on the trail.

Space.Host.ExecutingObject.TrailRenderer.UseLightProbes = true



WidthMultiplier

float WidthMultiplier { get;set; }

Set an overall multiplier that is applied to the TrailRenderer.widthCurve to get the final width of the trail.

Space.Host.ExecutingObject.TrailRenderer.WidthMultiplier = 2


--Make a slider change the Trail Renderer's Width Multiplier
--[Add "slider" and "trailrenderer" references to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject

slider = Space.Host.GetReference("slider").UISlider
trailrenderer = Space.Host.GetReference("trailrenderer").TrailRenderer


OVC = function()
trailrenderer.WidthMultiplier = slider.Value * 10 --0 to 10
end

slider.OnValueChanged(OVC)