Sinespace Client  2023.2.17543
Client-side scripting for Sinespace
SineSpace.Scripting.Types.SMaterial Class Reference

Public Member Functions

SMaterial Instantiate ()
 Return a new SMaterial from old. More...
 
void SetFloat (string key, float value)
 Set a named float value. More...
 
float GetFloat (string key)
 Get a named float value. More...
 
void SetColor (string key, SColor color)
 Set a named color value. More...
 
void SetColor (string key, float r, float g, float b, float a)
 Set a named color value. More...
 
SColor GetColor (string key)
 Get a named color value. More...
 
void SetColor32 (string key, byte r, byte g, byte b, byte a)
 Set a named color value in color32 More...
 
void SetInt (string key, int value)
 Set a named int value. More...
 
int GetInt (string key)
 Get a named int value. More...
 
void SetTexture (string key, SResource value)
 Set a named texture. More...
 
SResource GetTexture (string key)
 Get a named texture. More...
 
void SetTextureOffset (string key, float x, float y)
 Set the placement offset of texture property name. More...
 
void SetTextureScale (string key, float x, float y)
 
void SetVector (string key, SVector value)
 Set named vector value. More...
 

Properties

string Name [get, set]
 Returns the name of current SMaterial More...
 
string Shader [get]
 Return the shader name of current SMaterial More...
 
int RenderQueue [get, set]
 Render queue of this material More...
 

Member Function Documentation

◆ GetColor()

SColor SineSpace.Scripting.Types.SMaterial.GetColor ( string  key)

Get a named color value.

Parameters
keyThe name of key.
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
Space.Log(mat.GetColor("_Color").ToString())

◆ GetFloat()

float SineSpace.Scripting.Types.SMaterial.GetFloat ( string  key)

Get a named float value.

Parameters
keyThe name of key.
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
Space.Log(mat.GetFloat("_Glossiness"))

◆ GetInt()

int SineSpace.Scripting.Types.SMaterial.GetInt ( string  key)

Get a named int value.

Parameters
keyThe name of key.
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
Space.Log(mat.GetInt("_IntValue"))

◆ GetTexture()

SResource SineSpace.Scripting.Types.SMaterial.GetTexture ( string  key)

Get a named texture.

Parameters
keyThe name of key
valueValue to set
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
local gt = mat.GetTexture("_MainTex")
Space.Log(gt.Name)
–print "Retrieved Texture"

◆ Instantiate()

SMaterial SineSpace.Scripting.Types.SMaterial.Instantiate ( )

Return a new SMaterial from old.

local cube=Space.Host.ExecutingObject
local cube2=cube.Children[1]
local mat1=cube.Renderer.Material
local newMat=mat1.Instantiate()
newMat.SetColor("_Color",Color.Red)
cube2.Renderer.Material=newMat
–at this moment, cube2 will turn to red but cube will keep original color.

◆ SetColor() [1/2]

void SineSpace.Scripting.Types.SMaterial.SetColor ( string  key,
float  r,
float  g,
float  b,
float  a 
)

Set a named color value.

Parameters
keyThe name of key.
rred
ggreen
bblue
aalpha
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
mat.SetColor("_Color",1,0,0,1)

◆ SetColor() [2/2]

void SineSpace.Scripting.Types.SMaterial.SetColor ( string  key,
SColor  color 
)

Set a named color value.

Parameters
keyThe name of key.
colorThe color you want to use.
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
mat.SetColor("_Color",Color.Red)

◆ SetColor32()

void SineSpace.Scripting.Types.SMaterial.SetColor32 ( string  key,
byte  r,
byte  g,
byte  b,
byte  a 
)

Set a named color value in color32

Parameters
keyThe name of key.
rred
ggreen
bblue
aalpha
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
mat.SetColor32("_Color",0,255,0,255)

◆ SetFloat()

void SineSpace.Scripting.Types.SMaterial.SetFloat ( string  key,
float  value 
)

Set a named float value.

Parameters
keyThe name of key
valueValue to set
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
mat.SetFloat("_Glossiness",1)

◆ SetInt()

void SineSpace.Scripting.Types.SMaterial.SetInt ( string  key,
int  value 
)

Set a named int value.

Parameters
keyThe name of key
valueValue to set
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
mat.SetInt("_IntValue",2)

◆ SetTexture()

void SineSpace.Scripting.Types.SMaterial.SetTexture ( string  key,
SResource  value 
)

Set a named texture.

Parameters
keyThe name of key
valueValue to set
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
local texture=Space.Resources[1]
mat.SetTexture("_MainTex",texture)

◆ SetTextureOffset()

void SineSpace.Scripting.Types.SMaterial.SetTextureOffset ( string  key,
float  x,
float  y 
)

Set the placement offset of texture property name.

Parameters
keyThe name of key
valueValue to set
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
mat.SetTextureOffset("_MainTex",0.5,0.5)

◆ SetTextureScale()

void SineSpace.Scripting.Types.SMaterial.SetTextureScale ( string  key,
float  x,
float  y 
)

Set the placement offset of texture property name.

Parameters
keyThe name of key
valueValue to set
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
mat.SetTextureScale("_MainTex",0.5,0.5)

◆ SetVector()

void SineSpace.Scripting.Types.SMaterial.SetVector ( string  key,
SVector  value 
)

Set named vector value.

Parameters
keyThe name of key
valueValue to set
local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
mat.SetVector("_Vector",Vector.New(2,2,2))

Property Documentation

◆ Name

string SineSpace.Scripting.Types.SMaterial.Name
getset

Returns the name of current SMaterial

local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
Space.Log(mat.Name)

◆ RenderQueue

int SineSpace.Scripting.Types.SMaterial.RenderQueue
getset

Render queue of this material

local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
–set value
mat.RenderQueue=3000
–get value
Space.Log(mat.RenderQueue)

◆ Shader

string SineSpace.Scripting.Types.SMaterial.Shader
get

Return the shader name of current SMaterial

local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
Space.Log(mat.Shader)