U3D_TobaccoWarehouseISMDTSy.../Assets/OutlineEffect/Samples/Demo/MaterialSwitcher.cs

22 lines
530 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace cakeslice
{
public class MaterialSwitcher : MonoBehaviour
{
public Material target;
public int index;
public void Update()
{
if(Input.GetKeyDown(KeyCode.M))
{
Material[] materials = GetComponent<Renderer>().materials;
materials[index] = target;
GetComponent<Renderer>().materials = materials;
}
}
}
}