- color
- CopyPropertiesFromMaterial
- GetColor
- GetFloat
- GetMatrix
- GetTag
- GetTextureOffset
- GetTextureScale
- GetTexture
- GetVector
- HasProperty
- Lerp
- mainTextureOffset
- mainTextureScale
- mainTexture
- Material
- passCount
- renderQueue
- SetColor
- SetFloat
- SetMatrix
- SetPass
- SetTextureOffset
- SetTextureScale
- SetTexture
- SetVector
- shader
Material.GetTag 获取标签
function GetTag (tag : string, searchFallbacks : bool, defaultValue : string = "") : string
Description描述
Get the value of material's shader tag.
获取材质着色器的标签值
If the material's shader does not define the tag, defaultValue is returned.
如果材质的着色器未定义标签,则返回默认值。
If searchFallbacks is true then this function will look for tag in all subshaders and all fallbacks.If seachFallbacks is false then only the currently used subshader will be queried for the tag.
如果 searchFallbacks 是true此函数将查找所有的子级着色器(subshader)和所有的后备标签。如果 seachFallbacks 是false此函数仅在当前使用的子级着色器(subshader)中查询标签。
Using GetTag without searching through fallbacks makes it possible to detect which subshader is currently being used: add a custom tag to each subshader with different value, and query the value at run time. For example, Unity Pro's water uses this function to detect when the shader falls back to non-reflective one, and turns off reflection camera in that case.
使用没有后备搜索的GetTag,检测当前正在使用的子级着色器(subshader): 将一个自定义的标签添加到每个具有不同的值的子级着色器(subshader)和查询在运行时的值。例如unity专业版的水,检测着色器何时将退化为于无反射,并使用此函数在这种情况下关闭反射相机。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public string materialTag = "RenderType";
void Start() {
string result = renderer.material.GetTag(materialTag, true, "Nothing");
if (result == "Nothing")
Debug.LogError(materialTag + " not found in " + renderer.material.shader.name);
else
Debug.Log("Tag found!, its value: " + result);
}
}
// Attach this to a gameObject that has a renderer
//把它附加在有renderer组件的游戏物体(gameobject)上
var materialTag = "RenderType";
function Start() {
var result : String = renderer.material.GetTag(materialTag, true, "Nothing");
if (result == "Nothing")
Debug.LogError (materialTag + " not found in " + renderer.material.shader.name);
else
Debug.Log ("Tag found!, its value: " + result);
}