uintAPi 之Renderer.material
Renderer.material
public Material material;
Returns the first instantiated Material assigned to the renderer.
Modifying material will change the material for this object only.
If the material is used by any other renderers, this will clone the shared material and start using it from now on.
Note:
This function automatically instantiates the materials and makes them unique to this renderer. It is your responsibility to destroy the materials when the game object is being destroyed. Resources.UnloadUnusedAssets also destroys the materials but it is usually only called when loading a new level.
void OnMouseEnter()
{
if(turretGo==null&&EventSystem.current.IsPointerOverGameObject())
{
renderer.material.color = Color.red;
}
}
void OnMouseExit()
{
renderer.material.color = Color.white;
}
//该代码实现当物体放在一个物体上显示红色,离开显示白色
官方代码实例:
using UnityEngine;
using System.Collections; // Change renderer's material each changeInterval
// seconds from the material array defined in the inspector.
public class ExampleClass : MonoBehaviour
{
public Material[] materials;
public float changeInterval = 0.33F;
public Renderer rend; void Start()
{
rend = GetComponent<Renderer>();
rend.enabled = true;
} void Update()
{
if (materials.Length == 0)
return; // we want this material index now
int index = Mathf.FloorToInt(Time.time / changeInterval); // take a modulo with materials count so that animation repeats
index = index % materials.Length; // assign it to the renderer
rend.sharedMaterial = materials[index];
}
}
uintAPi 之Renderer.material的更多相关文章
- Renderer.materials
修改方法 meshBody.renderer.materials[].mainTexture= clothes[]; meshBody.renderer.materials[]=maters[]; 以 ...
- Material
renderer.material 物理材质 实现二维图上的人物动作 新建Material,选择Shader(著色器)为transparent/diffuse(背景透明),将上图拉到背景图选项中. ...
- Unity修改Particles Render Material(Unity3D开发之二十三)
猴子原创,欢迎转载.转载请注明: 转载自Cocos2Der-CSDN,谢谢! 原文地址: http://blog.csdn.net/cocos2der/article/details/48372999 ...
- unity3D中 material中tiling和offset属性解释
贴图有可能是多行多列的一些图案组成的.当我们需要一帧,一帧的播放时候.也就是帧序列动画, 我们就需要用到tiling和offset两个属性, 默认图片的左下角为坐标圆点即:(0,0) tiling是图 ...
- unity, access material
MeshRenderer meshRenderer=gameObject.GetComponent<MeshRenderer>(); if(meshRende ...
- 【Unity3D】Unity3D中Material与ShareMaterial引用的区别
我们在使用Unity引擎的时候,有时候需要去修改某个物体上的Material,在Unity的Renderer类里,提供了两个方法接口供我们使用. Renderer.material和Renderer. ...
- 深入浅出聊优化:从Draw Calls到GC
前言: 刚开始写这篇文章的时候选了一个很土的题目...<Unity3D优化全解析>.因为这是一篇临时起意才写的文章,而且陈述的都是既有的事实,因而给自己“文(dou)学(bi)”加工留下的 ...
- 匹夫细说C#:庖丁解牛聊委托,那些编译器藏的和U3D给的
0x00 前言 由于工作繁忙所以距离上一篇博客已经过去一个多月的时间了,因此决心这个周末无论如何也得写点东西出来,既是总结也是分享.那么本文主要的内容集中在了委托的使用以及内部结构(当然还有事件了,但 ...
- Unity性能优化(4)-官方教程Optimizing graphics rendering in Unity games翻译
本文是Unity官方教程,性能优化系列的第四篇<Optimizing graphics rendering in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...
随机推荐
- Babel 配置选项
comments 是否去掉注释,true(默认)/false.
- centos7 安装部署jenkins
一.简介 jenkins是一个Java开发的开源持续集成工具,广泛用于项目开发,具有自动化构建.测试和部署等功能,它的运行需要Java环境. 二.搭建环境准备:# cat /etc/redhat-re ...
- c#跨线程访问的代码和窗体关闭退出死循环的代码
一:一段跨线程访问,给页面内的控件赋值的代码找了半天没找到,还得找了以前写的程序. 在这记下来吧 . 这是其他程序内可以跨线程访问的代码 . if (gridControl1.InvokeRequi ...
- Lonsdor K518ISE programs 2005 Ford Focus key in two minutes
A quick demonstration of Lonsdor K518ISE programming key for 2005 Ford Focus in two minutes. And for ...
- Dynamics AX 中的图片处理
1.从本地读取图片文件,并判断格式是否附合要求. FilenameFilter filter = [‘Image Files‘,‘*.bmp;*.jpg;*.gif;*.jpeg‘]; BinData ...
- 解决Spark On Yarn yarn-cluster模式下的No Suitable Driver问题
Spark版本:2.2.0_2.11 我们在项目中通过Spark SQL JDBC连接MySQL,在启动Driver/Executor执行的时候都碰到了这个问题.网上解决方案我们全部都试过了,奉上我们 ...
- php 随机生成ip
#随机生成IP 中国区 function randip(){ $ip_1 = -1; $ip_2 = -1; $ip_3 = rand(0,255); $ip_4 = rand(0,255); $ip ...
- net::ERR_CONNECTION_RESET 问题排查
后台服务器代码有问题 实体不对称,导致映射不对
- 无符号1byte转int
在java基本类型中byte是有正负之分,它的取值范围-128到127,有时候在网络编程里我们只需要正数,于是会约定1byte是无符号的,它的取值范围在255-0.那么我们怎么将无符号的1byte转为 ...
- Vmware Workstation - linux系统下 VmTools 安装
程序版本 : VMware® Workstation 14 Pro 系统环境 : win10 64位下 ubuntu-14.04.5-desktop-amd64 问题:在运行linux系统过程中,de ...