Line 62: | Line 62: | ||
}} | }} | ||
+ | ==Properties== | ||
{{ScriptFunction|string|Name|(get; set;)|Return a new SMaterial from old.|5= | {{ScriptFunction|string|Name|(get; set;)|Return a new SMaterial from old.|5= | ||
local cube=Space.Host.ExecutingObject<br> | local cube=Space.Host.ExecutingObject<br> | ||
local mat=cube.Renderer.Material<br> | local mat=cube.Renderer.Material<br> | ||
Space.Log(mat.Name) | Space.Log(mat.Name) | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|string|Shader|(get;)|Return the shader name of current SMaterial.|5= | ||
+ | local cube=Space.Host.ExecutingObject<br> | ||
+ | local mat=cube.Renderer.Material<br> | ||
+ | Space.Log(mat.Shader) | ||
}} | }} | ||
{{Scripting Navbox}} | {{Scripting Navbox}} |
The SMaterial class provides a wrapper around Materials used for rendering
Sets a shader property to value
local obj = Space.Host.ExecutingObject;
Gets the current value of a shader property.
local obj = Space.Host.ExecutingObject;
Space.Log(obj.Renderer.Material.GetFloat("_Glossiness"));
Sets a shader colour to the required one.
local obj = Space.Host.ExecutingObject;
local newColor = Color.New(1, 0, 0, 1);
Sets a shader colour to value (HDR variant, 0..1 values)
local obj = Space.Host.ExecutingObject;
Sets a shader colour to value (32-bit, 0..255 values)
local obj = Space.Host.ExecutingObject;
Sets a shader property to value. This can be a convenient way to work with Boolean values.
local obj = Space.Host.ExecutingObject;
Gets the current value of a shader property. This can be a convenient way to work with Boolean values.
local obj = Space.Host.ExecutingObject;
Space.Log(obj.Renderer.Material.GetInt("_GlossyReflections"));
Sets a object's specified texture map (specified in parameter 1) to the texture provided as a resource in parameter #2. The example script must be in a object with a '_MainTex' map, and that object should be set as a resource on the scripting runtime. Additionally, that object should be called 'dispobj'.
note also that this function can be used to set any of the texture maps by varying the value of the first parameter accordingly.
image = "mrlee.jpg"end
server = "https://middleware.systems/"
obj = Space.Host.GetReference("dispobj")
resrc = Space.WebServices.GetImage(server .. image)
obj.Renderer.Material.SetTexture("_MainTex", resrc)
Sets a texture offset to a value. IF USING FOR SCROLLING ANIMATION PLEASE US A ANIMATION NOT A SCRIPT
Sets a texture scale to a value. IF USING FOR SCROLLING ANIMATION PLEASE US A ANIMATION NOT A SCRIPT
Sets a shader property to value
Return a new SMaterial from old.
local cube2=cube.Children[1]
local mat1=cube.Renderer.Material
local newMat=mat1.Instantiate()
newMat.SetColor("_Color",Color.Red)
cube2.Renderer.Material=newMat
Return a new SMaterial from old.
local mat=cube.Renderer.Material
Return the shader name of current SMaterial.
local mat=cube.Renderer.Material
|