aego/material
Use material.Builtin("Flash"), Dissolve, Outline, Additive, PixelSnap, Unlit, Lit or LitMesh2D (Default is an alias for Unlit). Unknown names fault. Lit and LitMesh2D evaluate each selected light against the receiver's own surface normal. material.Assign writes the current world's SpriteRenderer or Mesh2D reference. For custom assets, assign an exported AssetRef<Material> or set the component's Material property.
package demo
import (
"aego/material"
"aego/log"
)
script SharedMaterial {
func Ready() {
ref := material.Builtin("Flash")
sprite := node.Get<SpriteRenderer>()
if sprite != nil {
material.Assign(node, ref)
}
weights := material.Vec4{0.1, 0.2, 0.3, 0.4}
log.Info("Flash reference available; numeric lane X=" + string(weights.X))
}
}
For a node with MaterialOverride, use SetFloat, SetInt, SetBool, SetVec2, SetVec3, SetVec4, SetColor, their matching getters, and Reset. An ordinary vec4 uses material.Vec4; a color parameter uses linear Color. Type mismatches fail before changing the node.
Functions
| Assign | (node NodeRef, material AssetRef<material>) | Changes the SpriteRenderer or Mesh2D material reference in this world. |
| Builtin | (name string) AssetRef<material> | Returns Unlit (Default), Additive, Flash, Dissolve, Outline or PixelSnap. Lit belongs to the lighting module. |
| Shader | (name string) AssetRef<shader> | Returns the prepared shader reference for a named built-in material. |
| Vec4 | | Four numeric lanes, with no color-space conversion. |
Assign function
func Assign(node NodeRef, material AssetRef<material>)
Changes the SpriteRenderer or Mesh2D material reference in this world.
Example
material.Assign(node, material.Builtin("Flash"))
Builtin function
func Builtin(name string) AssetRef<material>
Returns Unlit (Default), Additive, Flash, Dissolve, Outline or PixelSnap. Lit belongs to the lighting module.
See the module example for this function in use.
Shader function
func Shader(name string) AssetRef<shader>
Returns the prepared shader reference for a named built-in material.
See the module example for this function in use.
- Vec4 value type Four numeric lanes, with no color-space conversion.