# SLineRenderer

## Index

### Functions Index

| Function Name                                                      |
| ------------------------------------------------------------------ |
| void [**SetPosition** ](#setposition)(int index, SVector position) |
| SVector [**GetPosition** ](#getposition)(int index)                |
| void [**SetPositions** ](#setpositions)(SVector\[] positions)      |
| SVector\[] [**GetPositions** ](#getpositions)()                    |
| void [**SetWidth** ](#setwidth)(float start, float end)            |
| void [**SetColors** ](#setcolors)(SColor start, SColor end)        |

### Properties Index

| Property Name                                               |
| ----------------------------------------------------------- |
| bool [**Enabled** ](#enabled)`get` `set`                    |
| bool [**ReceiveShadows** ](#receiveshadows)`get` `set`      |
| bool [**IsVisible** ](#isvisible)`get`                      |
| bool [**CastShadows** ](#castshadows)`get` `set`            |
| bool [**MotionVectors** ](#motionvectors)`get` `set`        |
| bool [**UseLightProbes** ](#uselightprobes)`get` `set`      |
| float [**StartWidth** ](#startwidth)`get` `set`             |
| float [**EndWidth** ](#endwidth)`get` `set`                 |
| float [**WidthMultiplier** ](#widthmultiplier)`get` `set`   |
| SColor [**StartColor** ](#startcolor)`get` `set`            |
| SColor [**EndColor** ](#endcolor)`get` `set`                |
| int [**PositionCount** ](#positioncount)`get` `set`         |
| bool [**UseWorldSpace** ](#useworldspace)`get` `set`        |
| bool [**Loop** ](#loop)`get` `set`                          |
| int [**NumCornerVertices** ](#numcornervertices)`get` `set` |
| int [**NumCapVertices** ](#numcapvertices)`get` `set`       |
| int [**TextureMode** ](#texturemode)`get` `set`             |
| int [**Alignment** ](#alignment)`get` `set`                 |
| SGameObject [**GameObject** ](#gameobject)`get`             |

## Functions

### SetPosition

void **SetPosition** (int index, [SVector](https://docs.sine.space/scripting/client-scripting-api-reference/types/svector) position)

*Set the position of a vertex in the line.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.SetPosition(1,Vector.New(0,0,0))
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--this object will continuously render a line between two different game objects

refObject1 = Space.Host.GetReference("object1") --Add in References section of Scripting Runtime Component
refObject2 = Space.Host.GetReference("object2") --Add in References section of Scripting Runtime Component

thisObject = Space.Host.ExecutingObject

function OnUpdateFunction()
  thisObject.LineRenderer.PositionCount = 2 --this is necessary 

  thisObject.LineRenderer.SetPosition(1,refObject1.WorldPosition)
  thisObject.LineRenderer.SetPosition(2,refObject2.WorldPosition)

end

thisObject.OnUpdate(OnUpdateFunction)
```

{% endtab %}
{% endtabs %}

### GetPosition

[SVector](https://docs.sine.space/scripting/client-scripting-api-reference/types/svector) **GetPosition** (int index)

*Get the position of a vertex in the line*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
vectorPosition = Space.Host.ExecutingObject.LineRenderer.GetPosition(1)
```

{% endtab %}
{% endtabs %}

### SetPositions

void **SetPositions** ([SVector](https://docs.sine.space/scripting/client-scripting-api-reference/types/svector)\[] positions)

*Set the positions of all vertices in the line.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
 Space.Host.ExecutingObject.LineRenderer.SetPositions({Vector.New(0,0,0) , Vector.New(1,1,1)})
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--this object will continuously render a line between two different game objects

refObject1 = Space.Host.GetReference("object1") --Add in References section of Scripting Runtime Component
refObject2 = Space.Host.GetReference("object2") --Add in References section of Scripting Runtime Component

thisObject = Space.Host.ExecutingObject

function OnUpdateFunction()
  thisObject.LineRenderer.PositionCount = 2 --this is necessary
  thisObject.LineRenderer.SetPositions({refObject1.WorldPosition,refObject2.WorldPosition})

end

thisObject.OnUpdate(OnUpdateFunction)
```

{% endtab %}
{% endtabs %}

### GetPositions

[SVector](https://docs.sine.space/scripting/client-scripting-api-reference/types/svector)\[] **GetPositions** ()

*Get the positions of all vertices in the line.*

{% tabs %}
{% tab title="Lua" %}

```lua
tableVectorPositions = Space.Host.ExecutingObject.LineRenderer.GetPositions()
```

{% endtab %}
{% endtabs %}

### SetWidth

void **SetWidth** (float start, float end)

*Set width at start and end*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.SetWidth(5,7)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script will make a slider set both the Line Renderer's Start Width and End Width
thisGameObject = Space.Host.ExecutingObject

refSlider = Space.Host.GetReference("Slider") --Add Reference to Scripting Runtime Component
refLineRenderer = Space.Host.GetReference("LineRenderer") --Add Reference to Scripting Runtime Component



OVC = function()
  local width = (refSlider.UISlider.Value * 5)  -- from 0 to 5
  refLineRenderer.LineRenderer.SetWidth(width,width)
end

refSlider.UISlider.OnValueChanged(OVC)
```

{% endtab %}
{% endtabs %}

### SetColors

void **SetColors** ([SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) start, [SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) end)

*Set color at start and end (Line shader necessary)*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.SetColors(Color.Red, Color.Blue)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking the object will open a color picker that changes both Line Renderer's Start Color and End Color

thisGameObject = Space.Host.ExecutingObject
originalStartColor = thisGameObject.LineRenderer.StartColor
originalEndColor = thisGameObject.LineRenderer.EndColor

OnChange = function(SColor) 
  thisGameObject.LineRenderer.SetColors(SColor,SColor) 
end

OnSelect = function(SColor)
    thisGameObject.LineRenderer.SetColors(SColor,SColor) 
end

OnCancel = function()
   thisGameObject.LineRenderer.SetColors(originalStartColor,originalEndColor) 
end

OnClick = function()
  Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalStartColor)
end


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

{% endtab %}
{% endtabs %}

## Properties

### Enabled

bool **Enabled** `get` `set`

*Makes the renderer visible if enabled.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.Enabled = false
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object toggles it's LineRenderer component On/Off

thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  thisObject.LineRenderer.Enabled =  not thisObject.LineRenderer.Enabled
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
```

{% endtab %}
{% endtabs %}

### ReceiveShadows

bool **ReceiveShadows** `get` `set`

*Enable this option to make the line display any shadows that are cast upon it.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.ReceiveShadows = false
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object toggles it's Recieve Shadows options

thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  thisObject.LineRenderer.ReceiveShadows =  not thisObject.LineRenderer.ReceiveShadows
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
```

{% endtab %}
{% endtabs %}

### IsVisible

bool **IsVisible** `get`

*To check if this renderer is visible.*

{% tabs %}
{% tab title="Lua" %}

```lua
isVisible = Space.Host.ExecutingObject.LineRenderer.IsVisible
```

{% endtab %}
{% endtabs %}

### CastShadows

bool **CastShadows** `get` `set`

*Specify if and how the line casts shadows when a suitable Light shine on it.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.CastShadows = true
```

{% endtab %}
{% endtabs %}

### MotionVectors

bool **MotionVectors** `get` `set`

*Specifies whether this renderer has a per-object motion vector pass. If set to true, this object will have a per-object motion vector pass rendered*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.MotionVectors = true
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object toggles it's Line Renderer's Motion Vectors (Per Object Motion or Force no motion)
thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  thisObject.LineRenderer.MotionVectors =  not thisObject.LineRenderer.MotionVectors
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
```

{% endtab %}
{% endtabs %}

### UseLightProbes

bool **UseLightProbes** `get` `set`

*The light probe interpolation type.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.UseLightProbes = true
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object toggles it's Light Probe between Off and Blend Mode

thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  thisObject.LineRenderer.UseLightProbes =  not thisObject.LineRenderer.UseLightProbes
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
```

{% endtab %}
{% endtabs %}

### StartWidth

float **StartWidth** `get` `set`

*Set the width at the start of the line.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.StartWidth = 1
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script will make a slider change the Line Renderers start width


thisGameObject = Space.Host.ExecutingObject

refSlider = Space.Host.GetReference("Slider") --Add Reference to Scripting Runtime Component
refLineRenderer = Space.Host.GetReference("LineRenderer") --Add Reference to Scripting Runtime Component

refSlider.UISlider.Value = refLineRenderer.LineRenderer.StartWidth / 2 --initial position of slider

OVC = function()
  refLineRenderer.LineRenderer.StartWidth = (refSlider.UISlider.Value * 2)  -- from 0 to 2
end

refSlider.UISlider.OnValueChanged(OVC)
```

{% endtab %}
{% endtabs %}

### EndWidth

float **EndWidth** `get` `set`

*Set the width at the end of the line.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.EndWidth = 2
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script will make a slider change the Line Renderer's End Width
thisGameObject = Space.Host.ExecutingObject

refSlider = Space.Host.GetReference("Slider") --Add Reference to Scripting Runtime Component
refLineRenderer = Space.Host.GetReference("LineRenderer") --Add Reference to Scripting Runtime Component

refSlider.UISlider.Value = refLineRenderer.LineRenderer.EndWidth / 2 --initial position of slider

OVC = function()
  refLineRenderer.LineRenderer.EndWidth = (refSlider.UISlider.Value * 2)  -- from 0 to 2
end

refSlider.UISlider.OnValueChanged(OVC)
```

{% endtab %}
{% endtabs %}

### WidthMultiplier

float **WidthMultiplier** `get` `set`

*Set an overall multiplier that is applied to the LineRenderer.widthCurve to get the final width of the line.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.WidthMultiplier = 1.2
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script will make a slider change the Line Renderer's Width Multiplier
thisGameObject = Space.Host.ExecutingObject

refSlider = Space.Host.GetReference("Slider") --Add Reference to Scripting Runtime Component
refLineRenderer = Space.Host.GetReference("LineRenderer") --Add Reference to Scripting Runtime Component

refSlider.UISlider.Value = refLineRenderer.LineRenderer.WidthMultiplier / 5 --initial position of slider

OVC = function()
  refLineRenderer.LineRenderer.WidthMultiplier = (refSlider.UISlider.Value * 5)  -- from 0 to 5
end

refSlider.UISlider.OnValueChanged(OVC)
```

{% endtab %}
{% endtabs %}

### StartColor

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **StartColor** `get` `set`

*Set the color at the start of the line.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.StartColor = Color.Red
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking the object will open a color picker that changes the Line Renderer's Start Color

thisGameObject = Space.Host.ExecutingObject
originalColor = thisGameObject.LineRenderer.StartColor

OnChange = function(SColor) 
  thisGameObject.LineRenderer.StartColor = SColor
end

OnSelect = function(SColor)
  thisGameObject.LineRenderer.StartColor = SColor
end

OnCancel = function()
  thisGameObject.LineRenderer.StartColor = originalColor
end

OnClick = function()
  Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalColor)
end


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

{% endtab %}
{% endtabs %}

### EndColor

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **EndColor** `get` `set`

*Set the color at the end of the line.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.EndColor = Color.Blue
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking the object will open a color picker that changes the Line Renderer's End Color

thisGameObject = Space.Host.ExecutingObject
originalColor = thisGameObject.LineRenderer.EndColor

OnChange = function(SColor) 
  thisGameObject.LineRenderer.EndColor = SColor
end

OnSelect = function(SColor)
  thisGameObject.LineRenderer.EndColor = SColor
end

OnCancel = function()
  thisGameObject.LineRenderer.EndColor = originalColor
end

OnClick = function()
  Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalColor)
end


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

{% endtab %}
{% endtabs %}

### PositionCount

int **PositionCount** `get` `set`

*Set/get the number of vertices.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.PositionCount = 10
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script will make a slider change the Line Renderer's Position Count
thisGameObject = Space.Host.ExecutingObject

refSlider = Space.Host.GetReference("Slider") --Add Reference to Scripting Runtime Component
refLineRenderer = Space.Host.GetReference("LineRenderer") --Add Reference to Scripting Runtime Component

refSlider.UISlider.Value = refLineRenderer.LineRenderer.PositionCount  / 20 --initial position of slider

OVC = function()
  refLineRenderer.LineRenderer.PositionCount  = refSlider.UISlider.Value * 20  -- from 0 to 20
end

refSlider.UISlider.OnValueChanged(OVC)
```

{% endtab %}
{% endtabs %}

### UseWorldSpace

bool **UseWorldSpace** `get` `set`

*If enabled, the points are considered as world space coordinates. If disabled, they are local to the transform of the GameObject to which this component is attached.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.UseWorldSpace  = true
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object toggles it's Use World Space option

thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  thisObject.LineRenderer.UseWorldSpace = not   thisObject.LineRenderer.UseWorldSpace

end


thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
```

{% endtab %}
{% endtabs %}

### Loop

bool **Loop** `get` `set`

*Enable this to connect the first and last positions of the line, and form a closed loop.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.Loop = true
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object toggles it's Loop option

thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  thisObject.LineRenderer.Loop = not   thisObject.LineRenderer.Loop

end


thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
```

{% endtab %}
{% endtabs %}

### NumCornerVertices

int **NumCornerVertices** `get` `set`

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

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.NumCornerVertices = 2
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script will make a slider change the Line Renderer's Corner Vertices
thisGameObject = Space.Host.ExecutingObject

refSlider = Space.Host.GetReference("Slider") --Add Reference to Scripting Runtime Component
refLineRenderer = Space.Host.GetReference("LineRenderer") --Add Reference to Scripting Runtime Component

refSlider.UISlider.Value = refLineRenderer.LineRenderer.NumCornerVertices  / 10 --initial position of slider

OVC = function()
  refLineRenderer.LineRenderer.NumCornerVertices  = refSlider.UISlider.Value * 10  -- from 0 to 10
end

refSlider.UISlider.OnValueChanged(OVC)
```

{% endtab %}
{% endtabs %}

### NumCapVertices

int **NumCapVertices** `get` `set`

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

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.NumCapVertices = 2
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script will make a slider change the Line Renderer's End Cap Vertices
thisGameObject = Space.Host.ExecutingObject

refSlider = Space.Host.GetReference("Slider") --Add Reference to Scripting Runtime Component
refLineRenderer = Space.Host.GetReference("LineRenderer") --Add Reference to Scripting Runtime Component

refSlider.UISlider.Value = refLineRenderer.LineRenderer.NumCapVertices  / 20 --initial position of slider

OVC = function()
  refLineRenderer.LineRenderer.NumCapVertices  = refSlider.UISlider.Value * 20  -- from 0 to 10
end

refSlider.UISlider.OnValueChanged(OVC)
```

{% endtab %}
{% endtabs %}

### TextureMode

int **TextureMode** `get` `set`

*Control how the Texture is applied to the line. (0-3)*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.TextureMode = 2
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object toggles between it's 4 Texture Modes

thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  if thisObject.LineRenderer.TextureMode == 3 then
    thisObject.LineRenderer.TextureMode = 0
  else 
    thisObject.LineRenderer.TextureMode = thisObject.LineRenderer.TextureMode + 1
  end
end


thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
```

{% endtab %}
{% endtabs %}

### Alignment

int **Alignment** `get` `set`

*Set the direction that the line faces. (0 or 1)*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.LineRenderer.Alignment = 1
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object toggles it's Alignment option between View (0) and Transform Z (1)

thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  if thisObject.LineRenderer.Alignment == 0 then
    thisObject.LineRenderer.Alignment = 1
  else thisObject.LineRenderer.Alignment = 0
  end

end


thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
```

{% endtab %}
{% endtabs %}

### GameObject

[SGameObject](https://docs.sine.space/scripting/client-scripting-api-reference/types/sgameobject) **GameObject** `get`

*Property Description*

{% tabs %}
{% tab title="Lua" %}

```lua
theGameObject = Space.Host.ExecutingObject.LineRenderer.GameObject
```

{% endtab %}
{% endtabs %}
