实现目标:鼠标点击物体更换物体材质
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class CMCSBottleClick : MonoBehaviour
{
Material[] Mater = new Material[2];//材质
public GameObject tianpingShow;
public GameObject PEOBottle;
//绑定按钮
private void Awake()
{
PEOBottle.GetComponent<PEOBottleClick>().enabled = false;//代码组件关闭
}
private void Start()
{
Mater[0] = Resources.Load<Material>("Material/meterial0");//材质替换
Mater[1] = Resources.Load<Material>("Material/meterial27");
}
void OnMouseDown()
{
StartCoroutine("delayMedicalShow0");
tianpingShow.GetComponent<MeshRenderer>().material = Mater[1];//称量显示
this.GetComponent<Collider>().enabled = false;
}
IEnumerator delayMedicalShow0()
{
yiel