# Canvas Renderer Set Material

[Rendering](../index.md) / [Canvas Renderer](index.md) / **Canvas Renderer Set Material** Material, Index

## Description

Executes the Set Material method on the Canvas Renderer component

## Parameters

| Name | Description |
| :--- | :---------- |
| Material |  |
| Index |  |

## Code

```cs
// <auto-generated>
// This script was automatically generated using the Visual Script Transpiler.
// Do not modify. Changes to this file will be lost when updating the package.
// </auto-generated>

using System;
using UnityEngine;
using VisualScript.Icons;
using UnityEngine.Rendering;

namespace VisualScript.Runtime
{
    [Title("Canvas Renderer Set Material")]
    [Category("Rendering/Canvas Renderer/Set Material", "Material, Index")]
    [Description("Executes the Set Material method on the Canvas Renderer component")]
    
    [Image(typeof(IconEye), ColorTheme.Type.TextLight)]
    
    [Parameter("Material")]
    [Parameter("Index")]
    
    [Serializable]
    public class GenInstructionCanvasRenderer_SetMaterial_2_MaterialMaterial_IntIndex : Instruction
    {
        [SerializeField] private GetGameObject m_CanvasRenderer = new GetGameObject(
            new GenTypeGameObject_CanvasRenderer()
        );
        
        [SerializeField] private GetMaterial m_Material = new GetMaterial();
        
        [SerializeField] private GetInteger m_Index = new GetInteger();
        
        protected override string GetTitle(GameObject source)
        {
            string method = TextUtils.ThemeAsKeyword("Set Material");
            return $"{this.m_CanvasRenderer} {method} ({this.m_Material}, {this.m_Index})";
        }
        
        protected override Awaitable Run(Args args)
        {
            CanvasRenderer component = this.m_CanvasRenderer.Get<CanvasRenderer>(args);
            if (component == null) return Done;
            
            component.SetMaterial(
                (Material) this.m_Material.Get(args),
                (int) this.m_Index.Get(args)
            );
            
            return Done;
        }
    }
}


```

