本文整理汇总了C#中Material.GetInstanceID方法的典型用法代码示例。如果您正苦于以下问题:C# Material.GetInstanceID方法的具体用法?C# Material.GetInstanceID怎么用?C# Material.GetInstanceID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Material
的用法示例。
在下文中一共展示了Material.GetInstanceID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateMaterialNew
string GenerateMaterialNew(ref System.Text.StringBuilder sbR,ref Material m)
{
string matName = m.name;
if(matNameFromTextureName && m.HasProperty ("_MainTex")){
Texture2D mT = m.GetTexture ("_MainTex") as Texture2D;
if(mT != null){
matName = m.GetTexture ("_MainTex").name;
}else{
Debug.Log ("Could not generate material from texture name (" + matName + "). No texture assigned");
}
}
bool instance = matName.Contains ("Instance");
if(instance && materialInstancePercautions) {
matName += "_(" + m.GetInstanceID () + ")";
}
if(matNameCache.Contains (matName) == false){
matNameCache.Add (matName);
sbR.AppendLine ("newmtl " + matName);
bool hasColor = m.HasProperty ("_Color");
if(hasColor){
Color matColor = m.color;
sbR.AppendLine ("Kd " + matColor.r + " " + matColor.g + " " + matColor.b);
float alpha = Mathf.Lerp (1,0,matColor.a);
sbR.AppendLine ("d " + alpha);
}
bool hasSpecular = m.HasProperty ("_SpecColor");
if (hasSpecular) {
Color specColor = m.GetColor ("_SpecColor");
sbR.AppendLine ("Ks " + specColor.r + " " + specColor.g + " " + specColor.b);
}
bool hasTexture = m.HasProperty ("_MainTex");
if (hasTexture) {
Texture2D mainTex = m.GetTexture ("_MainTex") as Texture2D;
if(mainTex != null){
Vector2 mainTexScale = m.GetTextureScale ("_MainTex");
if(mainTex.wrapMode == TextureWrapMode.Clamp){
sbR.AppendLine("-clamp on");
}
sbR.AppendLine ("s " + mainTexScale.x + " " + mainTexScale.y);
sbR.AppendLine ("map_Kd " + mainTex.name + ".png");
try{
if(exportTextures ){
Texture2D nT = new Texture2D(mainTex.width,mainTex.height,TextureFormat.ARGB32,false);
Color[] pxls = mainTex.GetPixels ();
nT.SetPixels (pxls);
byte[] pngEx = nT.EncodeToPNG ();
if(System.IO.File.Exists (exportFolder + "/" + mainTex.name + ".png") == false){
System.IO.File.WriteAllBytes (exportFolder + "/" + mainTex.name + ".png",pngEx);
}
}
}catch(System.Exception ex){
}
}
}
sbR.AppendLine ();
}
return matName;
}
示例2: GetMaterialAssetName
private string GetMaterialAssetName(Material material, MeshRenderer meshRenderer)
{
return GetMaterialName(material, meshRenderer) + "_" + material.GetInstanceID().ToString("X8");
}