Format
typescript
Material.SetTexture(name, tex)class: Material
Description
Set the Texture value of a material based on the property name.
This method assigns the specified texture to the material's property, such as the diffuse map, normal map, light map, etc.
Parameters
| param_name | type | description |
|---|---|---|
| name | string | The name of the property. |
| tex | Texture | The Texture value. |
Return
| type | description |
|---|---|
void |
Code Example
typescript
let material = Resources.Load<Material>(Material, "materialId");
let testTexture = Resources.Load<Texture2D>(Texture2D,"B41AA48C7A304D8FD8938F1FFEBF3E9C");
material.SetTexture("_MainTex",testTexture);
let _Tex = material.GetTexture("_MainTex");
Debug.Log("_MainTex : ",_Tex)