wiki.sine.space | sinespace

Difference between revisions of "Scripting/SRenderer"

From wiki.sine.space
Jump to: navigation, search
m
Line 1: Line 1:
 
A renderer is what makes an object appear on the screen.
 
A renderer is what makes an object appear on the screen.
  
The SRendererclass component interfaces with Unity's Renderer component, exposing its functions to scripting.
+
The SRenderer class component interfaces with Unity's Renderer component, exposing its functions to scripting.
  
=Members=
+
=Properties=
==Miscellaneous==
+
{{ScriptFunction|bool|IsVisible|{ get; }|Returns true if the renderer is visible on any camera.|5=<pre>
{{ScriptFunction|bool|IsVisible|{ get; }|Returns true if the renderer is visible on any camera.|5=
+
isVisible = Space.Host.ExecutingObject.Renderer.IsVisible</pre>|6=<pre></pre> }}
if(Space.Host.ExecutingObject.Renderer.IsVisible == true) then<br>&nbsp;Space.Log("The Object is Visible!");<br>else<br>&nbsp;Space.Log("The Object is Invisible!");<br>end}}
+
  
  
{{ScriptFunction|bool|Enabled|{ get; set; }|Get/Set if the rendered object is visible.|5=-- Hide/Show this Object --<br>function ShowObject(flag)<br>&nbsp;Space.Host.ExecutingObject.Renderer.Enabled = flag;<br>end<br><br>ShowObject(false);|6=<pre>--the below script will make this object disappear
+
{{ScriptFunction|bool|Enabled|{ get; set; }|Get/Set if the rendered object is visible.|5=<pre>Space.Host.ExecutingObject.Renderer.Enabled = false </pre>|6=<pre>--clicking this object will make it disappear/reappear
--for 10 seconds then reappear again (clickable)
+
--(Example: toilet being flushed)
+
  
 
thisGameObject = Space.Host.ExecutingObject
 
thisGameObject = Space.Host.ExecutingObject
  
 
DisappearCoroutine = function()
 
thisGameObject.Renderer.Enabled = false
 
coroutine.yield(10)
 
thisGameObject.Renderer.Enabled = true
 
end
 
  
 
OnClick = function()
 
OnClick = function()
Space.Host.StartCoroutine(DisappearCoroutine)
+
thisGameObject.Renderer.Enabled = not thisGameObject.Renderer.Enabled
 
end
 
end
  
 
thisGameObject.AddClickable()
 
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip="Flush me!"
 
 
thisGameObject.Clickable.OnClick(OnClick)</pre>}}
 
thisGameObject.Clickable.OnClick(OnClick)</pre>}}
  
==Materials==
+
 
 
{{ScriptFunction|SMaterial|Material|{ get; set; }|Get/Set the material instantiated to the renderer.|
 
{{ScriptFunction|SMaterial|Material|{ get; set; }|Get/Set the material instantiated to the renderer.|
5=-- Change the Object's Colour --<br>function SetColor(R, G, B, A)<br>&nbsp;Space.Host.ExecutingObject.Renderer.Material.SetColor("_Color", R, G, B, A);<br>end<br><br>SetColor(1.0, 0.5, 0.5, 1.0);}}
+
5=<pre>Space.Host.ExecutingObject.Renderer.Material.SetColor("_Color", 1.0, 0.5, 0.5, 1.0)</pre>|6=<pre></pre>}}
{{ScriptFunction|SMaterial|Materials[]|{ get; set; }|Get/Set all materials instantiated to the renderer.|5=local mats = {};<br>mats = Space.Host.ExecutingObject.Renderer.Materials;<br>mats[1].SetColor("_Color", 1.0, 1.0, 0.0, 0.5);}}
+
{{ScriptFunction|SMaterial|Materials[]|{ get; set; }|Get/Set all materials instantiated to the renderer.|5=<pre>mats = Space.Host.ExecutingObject.Renderer.Materials</pre>|6=<pre></pre>}}
 +
 
  
==Shared Materials==
 
 
{{ScriptFunction|SMaterial |SharedMaterial|{ get; set; }|Get/Set the shared material used by the renderer.|5=Refer to member Material.}}
 
{{ScriptFunction|SMaterial |SharedMaterial|{ get; set; }|Get/Set the shared material used by the renderer.|5=Refer to member Material.}}
 
{{ScriptFunction|SMaterial|SharedMaterials[]|{ get; set; }|Get/Set all shared materials used by the renderer.|5=Refer to member Materials.}}
 
{{ScriptFunction|SMaterial|SharedMaterials[]|{ get; set; }|Get/Set all shared materials used by the renderer.|5=Refer to member Materials.}}
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 14:26, 24 January 2022

A renderer is what makes an object appear on the screen.

The SRenderer class component interfaces with Unity's Renderer component, exposing its functions to scripting.

Properties

IsVisible

bool IsVisible { get; }

Returns true if the renderer is visible on any camera.

isVisible = Space.Host.ExecutingObject.Renderer.IsVisible



Enabled

bool Enabled { get; set; }

Get/Set if the rendered object is visible.

Space.Host.ExecutingObject.Renderer.Enabled = false 


--clicking this object will make it disappear/reappear

thisGameObject = Space.Host.ExecutingObject


OnClick = function()
thisGameObject.Renderer.Enabled = not thisGameObject.Renderer.Enabled
end

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


Material

SMaterial Material { get; set; }

Get/Set the material instantiated to the renderer.

Space.Host.ExecutingObject.Renderer.Material.SetColor("_Color", 1.0, 0.5, 0.5, 1.0)


Materials[]

SMaterial Materials[] { get; set; }

Get/Set all materials instantiated to the renderer.

mats = Space.Host.ExecutingObject.Renderer.Materials



SharedMaterial

SMaterial SharedMaterial { get; set; }

Get/Set the shared material used by the renderer.

Refer to member Material.


SharedMaterials[]

SMaterial SharedMaterials[] { get; set; }

Get/Set all shared materials used by the renderer.

Refer to member Materials.