wiki.sine.space | sinespace

Difference between revisions of "Scripting/SRenderer"

From wiki.sine.space
Jump to: navigation, search
m
Line 9: Line 9:
  
  
{{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>
+
{{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
--the below script will make this object disappear
+
 
--for 10 seconds then reappear again (clickable)
 
--for 10 seconds then reappear again (clickable)
 
--(Example: toilet being flushed)
 
--(Example: toilet being flushed)
Line 24: Line 23:
  
 
OnClick = function()
 
OnClick = function()
thisGameObject.Active = false
+
Space.Host.StartCoroutine(DisappearCoroutine)
 
end
 
end
  
 
thisGameObject.AddClickable()
 
thisGameObject.AddClickable()
 
thisGameObject.Clickable.Tooltip="Flush me!"
 
thisGameObject.Clickable.Tooltip="Flush me!"
thisGameObject.Clickable.OnClick(OnClick)
+
thisGameObject.Clickable.OnClick(OnClick)</pre>}}
 
+
Space.Host.StartCoroutine(DisappearCoroutine)</pre>}}
+
  
 
==Materials==
 
==Materials==

Revision as of 12:52, 13 July 2021

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.

Members

Miscellaneous

IsVisible

bool IsVisible { get; }

Returns true if the renderer is visible on any camera.

if(Space.Host.ExecutingObject.Renderer.IsVisible == true) then
 Space.Log("The Object is Visible!");
else
 Space.Log("The Object is Invisible!");
end



Enabled

bool Enabled { get; set; }

Get/Set if the rendered object is visible.

-- Hide/Show this Object --
function ShowObject(flag)
 Space.Host.ExecutingObject.Renderer.Enabled = flag;
end

ShowObject(false);


--the below script will make this object disappear
--for 10 seconds then reappear again (clickable)
--(Example: toilet being flushed)

thisGameObject = Space.Host.ExecutingObject


DisappearCoroutine = function()
thisGameObject.Renderer.Enabled = false
coroutine.yield(10)
thisGameObject.Renderer.Enabled = true
end

OnClick = function()
Space.Host.StartCoroutine(DisappearCoroutine)
end

thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip="Flush me!"
thisGameObject.Clickable.OnClick(OnClick)

Materials

Material

SMaterial Material { get; set; }

Get/Set the material instantiated to the renderer.

-- Change the Object's Colour --
function SetColor(R, G, B, A)
 Space.Host.ExecutingObject.Renderer.Material.SetColor("_Color", R, G, B, A);
end

SetColor(1.0, 0.5, 0.5, 1.0);


Materials[]

SMaterial Materials[] { get; set; }

Get/Set all materials instantiated to the renderer.

local mats = {};
mats = Space.Host.ExecutingObject.Renderer.Materials;
mats[1].SetColor("_Color", 1.0, 1.0, 0.0, 0.5);


Shared 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.