当前位置:网站首页>Unity: PC development, click the object with the mouse to trigger the object to change the material
Unity: PC development, click the object with the mouse to trigger the object to change the material
2022-07-21 01:24:00 【Little sun works hard every day】
Achieve the goal : Click the object with the mouse to change the material of the object
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class CMCSBottleClick : MonoBehaviour
{
Material[] Mater = new Material[2];// texture of material
public GameObject tianpingShow;
public GameObject PEOBottle;
// Bind button
private void Awake()
{
PEOBottle.GetComponent<PEOBottleClick>().enabled = false;// Code component shutdown
}
private void Start()
{
Mater[0] = Resources.Load<Material>("Material/meterial0");// Material replacement
Mater[1] = Resources.Load<Material>("Material/meterial27");
}
void OnMouseDown()
{
StartCoroutine("delayMedicalShow0");
tianpingShow.GetComponent<MeshRenderer>().material = Mater[1];// Weighing display
this.GetComponent<Collider>().enabled = false;
}
IEnumerator delayMedicalShow0()
{
yield return new WaitForSeconds(1f);
tianpingShow.GetComponent<MeshRenderer>().material = Mater[0]; // Material replacement
StartCoroutine("delayMedicalContainerAnimPlay0");
}
IEnumerator delayMedicalContainerAnimPlay0()
{
yield return new WaitForSeconds(2.5f);
PEOBottle.GetComponent<PEOBottleClick>().enabled = true;
}
}
边栏推荐
- 1002 A+B for Polynomials
- Baidu PaddlePaddle easydl helps manufacturing enterprises with intelligent transformation
- Classes and objects (top)
- acwing 870. 约数个数
- Unity shader shader learning (I)
- Deit: attention can also be distilled
- 力扣124题:二叉树中的最大路径和
- 数据库系统原理与应用教程(031)—— MySQL 的数据完整性(四):定义外键(FOREIGN KEY)
- 网络安全技术的新趋势探讨
- Is it difficult to develop a test platform?
猜你喜欢
acwing 871. 约数之和
Unity shader shader learning (I)
已解决No module named ‘flask_misaka‘【BUG解决】
DNS domain name resolution
Baidu PaddlePaddle easydl helps manufacturing enterprises with intelligent transformation
通过TCP方式点灯
Build product array
acwing 867. 分解质因数
The way to practice and play strange: the meaning of NPM global installation and local installation in nodejs, and the difference between global installation and local installation in NPM
十分钟生成影视级室内设计效果,红星美凯龙设计云如何升级传统家居行业
随机推荐
【概率和计数】
金仓数据库的单节点如何转集群
Harbor—镜像仓库
实习打怪之路:npm和yarn的区别
Encapsulation, inheritance, polymorphism
数据库系统原理与应用教程(031)—— MySQL 的数据完整性(四):定义外键(FOREIGN KEY)
Warning FailedScheduling 8s default-scheduler 0/3 nodes are available: 1 Insufficient memory
网络安全技术的新趋势探讨
Isecops intelligent security operation technology system framework
音视频入门——H.264编码(宏块+片+帧)浅析
Bubble sort and quick sort
模糊照片秒变高清大图,飞桨PPDE带你复现图像恢复模型CMFNet
Deit: attention can also be distilled
Solution to remote access failure of docker installation MySQL in virtual machine
Key technologies of network security knowledge map
合规视角下的数据安全技术前沿与应用
AVL tree
DNS解析过程
翻译UE官方关于UObject基础的文档
Online sandbox collection