wiki.sine.space | sinespace

Difference between revisions of "Scripting/SLineRenderer"

From wiki.sine.space
Jump to: navigation, search
(Created page with " =Public Member Functions= {{ScriptFunction|void|SetPosition|(int index, SVector position);|Set the position of a vertex in the line.|5=<pre></pre>|6=<pre></pre>}} {{ScriptF...")
 
Line 2: Line 2:
 
=Public Member Functions=
 
=Public Member Functions=
  
{{ScriptFunction|void|SetPosition|(int index, SVector position);|Set the position of a vertex in the line.|5=<pre></pre>|6=<pre></pre>}}
+
{{ScriptFunction|void|SetPosition|(int index, SVector position);|Set the position of a vertex in the line.|5=<pre></pre>|6=<pre>--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)</pre>}}
  
 
{{ScriptFunction|SVector|GetPosition|(int index);|Get the position of a vertex in the line|5=<pre></pre>|6=<pre></pre>}}
 
{{ScriptFunction|SVector|GetPosition|(int index);|Get the position of a vertex in the line|5=<pre></pre>|6=<pre></pre>}}
  
{{ScriptFunction|void|SetPositions|(SVector[] positions);|Set the positions of all vertices in the line.|5=<pre></pre>|6=<pre></pre>}}
+
{{ScriptFunction|void|SetPositions|(SVector[] positions);|Set the positions of all vertices in the line.|5=<pre></pre>|6=<pre>--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)</pre>}}
  
 
{{ScriptFunction|SVector[]|GetPositions|();|description|5=<pre></pre>|6=<pre></pre>}}
 
{{ScriptFunction|SVector[]|GetPositions|();|description|5=<pre></pre>|6=<pre></pre>}}
Line 18: Line 46:
 
=Properties=
 
=Properties=
  
{{ScriptFunction|bool|Enabled|{ get;set; }|Makes the rendered visible if enabled.|5=<pre></pre>|6=<pre></pre>}}
+
{{ScriptFunction|bool|Enabled|{ get;set; }|Makes the renderer visible if enabled.|5=<pre></pre>|6=<pre>--clicking this object toggles it's LineRenderer component On/Off
  
{{ScriptFunction|bool|ReceiveShadows|{ get;set; }|Enable this option to make the line display any shadows that are cast upon it.|5=<pre></pre>|6=<pre></pre>}}
+
thisObject = Space.Host.ExecutingObject
  
{{ScriptFunction|bool|IsVisible|{ get;set; }|To check if this renderer is visible.|5=<pre></pre>|6=<pre></pre>}}
+
function OnClickFunction()
 +
  thisObject.LineRenderer.Enabled = not thisObject.LineRenderer.Enabled
 +
end
  
{{ScriptFunction|bool|CastShadows|{ get;set; }|Specify if and how the line casts shadows when a suitable Light shine on it.|5=<pre></pre>|6=<pre></pre>}}
+
thisObject.AddClickable()
 +
thisObject.Clickable.OnClick(OnClickFunction)</pre>}}
 +
 
 +
{{ScriptFunction|bool|ReceiveShadows|{ get;set; }|Enable this option to make the line display any shadows that are cast upon it.|5=<pre></pre>|6=<pre>--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)</pre>}}
 +
 
 +
{{ScriptFunction|bool|IsVisible|{ get; }|To check if this renderer is visible.|5=<pre></pre>|6=}}
 +
 
 +
{{ScriptFunction|bool|CastShadows|{ get;set; }|Specify if and how the line casts shadows when a suitable Light shine on it.|5=<pre></pre>|6=<pre>--clicking this object toggles between it's cast shadows option
 +
 
 +
thisObject = Space.Host.ExecutingObject
 +
 
 +
function OnClickFunction()
 +
  thisObject.LineRenderer.CastShadows =  not thisObject.LineRenderer.CastShadows
 +
end
 +
 
 +
thisObject.AddClickable()
 +
thisObject.Clickable.OnClick(OnClickFunction)</pre>}}
  
 
{{ScriptFunction|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|5=<pre></pre>|6=<pre></pre>}}
 
{{ScriptFunction|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|5=<pre></pre>|6=<pre></pre>}}
  
{{ScriptFunction|bool|UseLightProbes|{ get;set; }|The light probe interpolation type.|5=<pre></pre>|6=<pre></pre>}}
+
{{ScriptFunction|bool|UseLightProbes|{ get;set; }|The light probe interpolation type.|5=<pre></pre>|6=<pre>--clicking this object toggles it's Light Probe between Off and Blend Mode
  
{{ScriptFunction|float |StartWidth|{ get;set; }|Set the width at the start of the line.|5=<pre></pre>|6=<pre></pre>}}
+
thisObject = Space.Host.ExecutingObject
  
{{ScriptFunction|float |EndWidth|{ get;set; }|Set the width at the end of the line.|5=<pre></pre>|6=<pre></pre>}}
+
function OnClickFunction()
 +
  thisObject.LineRenderer.UseLightProbes = not thisObject.LineRenderer.UseLightProbes
 +
end
  
{{ScriptFunction|float |WidthMultiplier|{ get;set; }|Set an overall multiplier that is applied to the LineRenderer.widthCurve to get the final width of the line.|5=<pre></pre>|6=<pre></pre>}}
+
thisObject.AddClickable()
 +
thisObject.Clickable.OnClick(OnClickFunction)</pre>}}
 +
 
 +
{{ScriptFunction|float|StartWidth|{ get;set; }|Set the width at the start of the line.|5=<pre></pre>|6=<pre></pre>}}
 +
 
 +
{{ScriptFunction|float|EndWidth|{ get;set; }|Set the width at the end of the line.|5=<pre></pre>|6=<pre></pre>}}
 +
 
 +
{{ScriptFunction|float|WidthMultiplier|{ get;set; }|Set an overall multiplier that is applied to the LineRenderer.widthCurve to get the final width of the line.|5=<pre></pre>|6=<pre></pre>}}
  
 
{{ScriptFunction|SColor|StartColor|{ get;set; }|Set the color at the start of the line.|5=<pre></pre>|6=<pre></pre>}}
 
{{ScriptFunction|SColor|StartColor|{ get;set; }|Set the color at the start of the line.|5=<pre></pre>|6=<pre></pre>}}
Line 42: Line 106:
 
{{ScriptFunction|int|PositionCount|{ get;set; }|Set/get the number of vertices.|5=<pre></pre>|6=<pre></pre>}}
 
{{ScriptFunction|int|PositionCount|{ get;set; }|Set/get the number of vertices.|5=<pre></pre>|6=<pre></pre>}}
  
{{ScriptFunction|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.|5=<pre></pre>|6=<pre></pre>}}
+
{{ScriptFunction|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.|5=<pre></pre>|6=<pre>--clicking this object toggles it's Use World Space option
  
{{ScriptFunction|bool|Loop|{ get;set; }|Enable this to connect the first and last positions of the line, and form a closed loop.|5=<pre></pre>|6=<pre></pre>}}
+
thisObject = Space.Host.ExecutingObject
 +
 
 +
function OnClickFunction()
 +
  thisObject.LineRenderer.UseWorldSpace = not  thisObject.LineRenderer.UseWorldSpace
 +
 
 +
end
 +
 
 +
 
 +
thisObject.AddClickable()
 +
thisObject.Clickable.OnClick(OnClickFunction)</pre>}}
 +
 
 +
{{ScriptFunction|bool|Loop|{ get;set; }|Enable this to connect the first and last positions of the line, and form a closed loop.|5=<pre></pre>|6=<pre>--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)</pre>}}
  
 
{{ScriptFunction|int|NumCornerVertices|{ get;set; }|Set this to a value greater than 0, to get rounded corners between each segment of the line.|5=<pre></pre>|6=<pre></pre>}}
 
{{ScriptFunction|int|NumCornerVertices|{ get;set; }|Set this to a value greater than 0, to get rounded corners between each segment of the line.|5=<pre></pre>|6=<pre></pre>}}
Line 50: Line 136:
 
{{ScriptFunction|int|NumCapVertices|{ get;set; }|Set this to a value greater than 0, to get rounded corners on each end of the line.|5=<pre></pre>|6=<pre></pre>}}
 
{{ScriptFunction|int|NumCapVertices|{ get;set; }|Set this to a value greater than 0, to get rounded corners on each end of the line.|5=<pre></pre>|6=<pre></pre>}}
  
{{ScriptFunction|int|TextureMode|{ get;set; }|Control how the Texture is applied to the line. (0-3)|5=<pre></pre>|6=<pre></pre>}}
+
{{ScriptFunction|int|TextureMode|{ get;set; }|Control how the Texture is applied to the line. (0-3)|5=<pre></pre>|6=<pre>--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)</pre>}}
 +
 
 +
{{ScriptFunction|int|Alignment|{ get;set; }|Set the direction that the line faces. (0 or 1)|5=<pre></pre>|6=<pre>--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
 +
 
  
{{ScriptFunction|int|Alignment|{ get;set; }|Set the direction that the line faces. (0 or 1)|5=<pre></pre>|6=<pre></pre>}}
+
thisObject.AddClickable()
 +
thisObject.Clickable.OnClick(OnClickFunction)</pre>}}
  
  
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 08:35, 25 March 2022

Public Member Functions

SetPosition

void SetPosition (int index, SVector position);

Set the position of a vertex in the line.


--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)

GetPosition

SVector GetPosition (int index);

Get the position of a vertex in the line


SetPositions

void SetPositions (SVector[] positions);

Set the positions of all vertices in the line.


--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)

GetPositions

[[Scripting/SVector[]|SVector[]]] GetPositions ();

description


SetWidth

void SetWidth (float start, float end);

Set width at start and end


SetColors

void SetColors (SColor start, SColor end);

Set color at start and end (Line shader necessary)



Properties

Enabled

bool Enabled { get;set; }

Makes the renderer visible if enabled.


--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)

ReceiveShadows

bool ReceiveShadows { get;set; }

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


--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)

IsVisible

bool IsVisible { get; }

To check if this renderer is visible.


CastShadows

bool CastShadows { get;set; }

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


--clicking this object toggles between it's cast shadows option

thisObject = Space.Host.ExecutingObject

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

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

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


UseLightProbes

bool UseLightProbes { get;set; }

The light probe interpolation type.


--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)

StartWidth

float StartWidth { get;set; }

Set the width at the start of the line.


EndWidth

float EndWidth { get;set; }

Set the width at the end of the line.


WidthMultiplier

float WidthMultiplier { get;set; }

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


StartColor

SColor StartColor { get;set; }

Set the color at the start of the line.


EndColor

SColor EndColor { get;set; }

Set the color at the end of the line.


PositionCount

int PositionCount { get;set; }

Set/get the number of vertices.


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.


--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)

Loop

bool Loop { get;set; }

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


--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)

NumCornerVertices

int NumCornerVertices { get;set; }

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


NumCapVertices

int NumCapVertices { get;set; }

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


TextureMode

int TextureMode { get;set; }

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


--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)

Alignment

int Alignment { get;set; }

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


--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)