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) 用于调整碰撞对象的摩擦力和反弹效果. 二.创建物理材质 要创建物理材质 ...
随机推荐
- UVa 637 - Booklet Printing
题目:模拟输出n页书的装订打印状态. 分析:模拟.页数为(n+3)/ 4,仅仅有n不超过半篇时会输出半篇. 说明:好多曾经做过的题目(⊙_⊙). #include <cstdlib> #i ...
- jquery开发之第一个程序
前一段时间学习了js和css.可是发现好多的程序里面都用到了jquery当时本来想着先吧js弄熟了 再搞这个.后来发现不行,好多的程序好像是有益和自己为难似的,所以我决定接下来认认真真的把jquery ...
- uboot烧写命令--yaffs、jiffs和ubifs
如果要烧写的镜像的格式是yaffs2或者yaffs格式的,那么在往Nand Flash中烧写该镜像是必须采用nand write.yaffs,而不能采用nand write: nand write.y ...
- 第一篇 对Javascript中原型的深入理解
理解原型对象 在Javascript中不管什么时候,仅仅要创建一个新的函数,就会依据一组特定的规则为该函数创建一个prototype属性,这个属性指向函数的原型对象(这个对象的用途是包括能够有特定 ...
- hadoop下c++程序-天气实例
非常希望能在hadoop上做c++程序.自己对c++还是有点情节的,依据<hadoop权威指南中文第二版>Hadoop的Pipes进行了试验,并測试成功 #include <algo ...
- SharePoint 2013 App 示例之图片墙
应用程序实质上是 Web 应用程序.如果您知道如何生成 Web 应用程序,则您就知道如何生成 SharePoint 相关应用程序.您可以使用任何语言,如 HTML.JavaScript.PHP 或 . ...
- 有用的iOS网站地址
王巍 (@onevcat) 是一名 iOS 和 Unity3D 开发者,现旅居日本,正在寻求创意之源.http://swifter.tips/http://onevcat.com/2013/02/xc ...
- 一次Dapper高并发测试报告记录. 结果....
一直听说dapper的数据处理能力很强. 我也一直很喜欢. 不过最近的一次压力测试却出乎我的意料.... 好久没写东西,感觉自己都不知道怎么表达自己的意思了. 另外 这次的测试也是自己才开始的 . ...
- SQL insert失败时也会造成自增长字段加1
CREATE TABLE #test(id INT IDENTITY(1,1), NAME varchar(30)) INSERT #test(name)SELECT '41545' SELECT ...
- Thinkphp学习笔记-编辑工具Sublime license
选择[help]-[enter license] 直接输入注册码就可以了 ----- BEGIN LICENSE ----- Andrew Weber Single User License EA ...