unity, access material
MeshRenderer meshRenderer=gameObject.GetComponent<MeshRenderer>();
if(meshRenderer!=null){
Material material=meshRenderer.material;
if(material!=null){
do something with material
}
}
参考:
1,http://forum.unity3d.com/threads/is-it-necessary-to-destroy-the-instance-material-manaully-in-unity-3-5.146946/
2,Renderer.material
public Material material;
Description
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.
unity, access material的更多相关文章
- unity, access standard shared emission by script
unity 5.1.1f1 personal 用下面方法在脚本中设置standard shader的emssion: gameObject.GetComponent<MeshRenderer&g ...
- Unity -- 材质-Material和预设体-Prefabs
材质(Materials)用来把网格(Mesh)或粒子渲染器(Particle Renderers)贴到游戏对象上.他们在定义对象怎么被显示发挥重要组成部分.材质包括用于呈现网状或颗粒着色器的参考,所 ...
- unity, access scene ambient
lighting面板里设置的ambient color,在shader里访问是通过UNITY_LIGHTMODEL_AMBIENT这个变量. 它定义在UnityShaderVariables.cgin ...
- unity, access sprite of UGUI Image
首先需要using UnityEngine.UI; 然后调用下面语句就不报错了: Image.GetComponent<Image>().sprite 参考:http://answers. ...
- 记录一个Unity播放器插件的开发
背景 公司最近在做VR直播平台,VR开发我们用到了Unity,而在Unity中播放视频就需要一款视频插件,我们调研了几个视频插件,记录两个,如下: Unity视频插件调研 网上搜了搜,最流行的有以下两 ...
- 记录一款Unity VR视频播放器插件的开发
效果图 先上一个效果图: 背景 公司最近在做VR直播平台,VR开发我们用到了Unity,而在Unity中播放视频就需要一款视频插件,我们调研了几个视频插件,记录两个,如下: Unity视频插件调研 网 ...
- MaxScript 学习笔记【有转载】
1. string string类型的变量是一个数组,下列操作合法:strName = $.name -- output: "Shemmy_03" strName[1] --得到字 ...
- Unity访问Access数据库
首先,准备工作: 创建一个Access 数据库,命名AccessTest.accdb,添加一些数据用于测试 准备System.Data.dll与System.EnterpriseServices.dl ...
- 【Unity】11.5 物理材质 (Physics Material)
分类:Unity.C#.VS2015 创建日期:2016-05-02 一.简介 物理材质 (Physics Material) 用于调整碰撞对象的摩擦力和反弹效果. 二.创建物理材质 要创建物理材质 ...
随机推荐
- 读CRecordset
void CDictCol::LoadDictCol(void) { // 加载数据字典信息 CString cstrSql; cstrSql.Format("SELECT dc.TblID ...
- 强悍的javascript手势库
/** * Toucher * git:https://github.com/cometwo/Toucher-1 */ "use strict"; (function (root, ...
- End of Life check fails with NullPointerException
Checks if the running version of JIRA is approaching, or has reached End of Life. Details Type: Bug ...
- pm2-web
A web based monitor for PM2. Multiple hosts With the release of 0.11 pm2 no longer uses TCP sockets ...
- 怎样加入cocostudio生成的UI到项目
cocos2dx版本号:cocos2d-x-3.2alpha0 cocostudio版本号:V1.4.0.1 1.将cocostudio生成的UI文件复制到项目Resources目录 2.加入头文件, ...
- Ubuntu删除文件夹的命令
1. 删除文件夹的内容包括文件夹: rm -rf 文件夹的名字 (-r 是 循环的意思, f是不询问的意思) 2 .删除文件夹的内容不包括文件夹: rm -rf 文件夹的名字/* ...
- easyui radio 取值和赋值
1.html文件 <td><input id="client" type="text" name="client" sty ...
- Latex中为作者添加多个单位属性(IEEE模板)
\author{ \IEEEauthorblockN{name1 name1\IEEEauthorrefmark{1}\IEEEauthorrefmark{2}, name2 name2\IEEEa ...
- HDU 4901 The Romantic Hero 题解——S.B.S.
The Romantic Hero Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe ...
- wamp网站Forbidden You don't have permission to access
Forbidden You don't have permission to access 问题原因:apache的2.4的版本中 Require all denied 应该变成Require a ...