本文整理汇总了C#中UnityEngine.Material.GetTag方法的典型用法代码示例。如果您正苦于以下问题:C# Material.GetTag方法的具体用法?C# Material.GetTag怎么用?C# Material.GetTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Material
的用法示例。
在下文中一共展示了Material.GetTag方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckMaterial
public static string CheckMaterial(Material mat, BuildTarget buildTarget)
{
if (mat == null || mat.shader == null)
{
return null;
}
string shaderName = mat.shader.name;
int lOD = ShaderUtil.GetLOD(mat.shader);
bool flag = Array.Exists<string>(PerformanceChecks.kShadersWithMobileVariants, (string s) => s == shaderName);
bool flag2 = PerformanceChecks.IsMobileBuildTarget(buildTarget);
if (buildTarget == BuildTarget.Android && ShaderUtil.HasClip(mat.shader))
{
return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderWithClipAndroid", new object[0]);
}
if (!(mat.GetTag("PerformanceChecks", true).ToLower() == "false"))
{
if (flag)
{
if (flag2 && mat.HasProperty("_Color") && mat.GetColor("_Color") == new Color(1f, 1f, 1f, 1f))
{
return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderUsesWhiteColor", new object[]
{
"Mobile/" + shaderName
});
}
if (flag2 && shaderName.StartsWith("Particles/"))
{
return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderHasMobileVariant", new object[]
{
"Mobile/" + shaderName
});
}
if (shaderName == "RenderFX/Skybox" && mat.HasProperty("_Tint") && mat.GetColor("_Tint") == new Color(0.5f, 0.5f, 0.5f, 0.5f))
{
return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderMobileSkybox", new object[]
{
"Mobile/Skybox"
});
}
}
if (lOD >= 300 && flag2 && !shaderName.StartsWith("Mobile/"))
{
return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderExpensive", new object[0]);
}
if (shaderName.Contains("VertexLit") && mat.HasProperty("_Emission"))
{
Color color = mat.GetColor("_Emission");
if (color.r >= 0.5f && color.g >= 0.5f && color.b >= 0.5f)
{
return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderUseUnlit", new object[0]);
}
}
if (mat.HasProperty("_BumpMap") && mat.GetTexture("_BumpMap") == null)
{
return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderNoNormalMap", new object[0]);
}
}
return null;
}
示例2: GetPreviewType
private static MaterialEditor.PreviewType GetPreviewType(Material mat)
{
if ((UnityEngine.Object) mat == (UnityEngine.Object) null)
return MaterialEditor.PreviewType.Mesh;
string lower = mat.GetTag("PreviewType", false, string.Empty).ToLower();
if (lower == "plane")
return MaterialEditor.PreviewType.Plane;
return lower == "skybox" || (UnityEngine.Object) mat.shader != (UnityEngine.Object) null && mat.shader.name.Contains("Skybox") ? MaterialEditor.PreviewType.Skybox : MaterialEditor.PreviewType.Mesh;
}
示例3: CheckMaterial
public static string CheckMaterial(Material mat, BuildTarget buildTarget)
{
// ISSUE: object of a compiler-generated type is created
// ISSUE: variable of a compiler-generated type
PerformanceChecks.\u003CCheckMaterial\u003Ec__AnonStoreyBE materialCAnonStoreyBe = new PerformanceChecks.\u003CCheckMaterial\u003Ec__AnonStoreyBE();
if ((UnityEngine.Object) mat == (UnityEngine.Object) null || (UnityEngine.Object) mat.shader == (UnityEngine.Object) null)
return (string) null;
// ISSUE: reference to a compiler-generated field
materialCAnonStoreyBe.shaderName = mat.shader.name;
int lod = ShaderUtil.GetLOD(mat.shader);
// ISSUE: reference to a compiler-generated method
bool flag1 = Array.Exists<string>(PerformanceChecks.kShadersWithMobileVariants, new Predicate<string>(materialCAnonStoreyBe.\u003C\u003Em__22D));
bool flag2 = PerformanceChecks.IsMobileBuildTarget(buildTarget);
if (!(mat.GetTag("PerformanceChecks", true).ToLower() == "false"))
{
if (flag1)
{
if (flag2 && mat.HasProperty("_Color") && mat.GetColor("_Color") == new Color(1f, 1f, 1f, 1f))
{
// ISSUE: reference to a compiler-generated field
return PerformanceChecks.FormattedTextContent("Shader is using white color which does nothing; Consider using {0} shader for performance.", (object) ("Mobile/" + materialCAnonStoreyBe.shaderName));
}
// ISSUE: reference to a compiler-generated field
if (flag2 && materialCAnonStoreyBe.shaderName.StartsWith("Particles/"))
{
// ISSUE: reference to a compiler-generated field
return PerformanceChecks.FormattedTextContent("Consider using {0} shader on this platform for performance.", (object) ("Mobile/" + materialCAnonStoreyBe.shaderName));
}
// ISSUE: reference to a compiler-generated field
if (materialCAnonStoreyBe.shaderName == "RenderFX/Skybox" && mat.HasProperty("_Tint") && mat.GetColor("_Tint") == new Color(0.5f, 0.5f, 0.5f, 0.5f))
return PerformanceChecks.FormattedTextContent("Skybox shader is using gray color which does nothing; Consider using {0} shader for performance.", (object) "Mobile/Skybox");
}
// ISSUE: reference to a compiler-generated field
if (lod >= 300 && flag2 && !materialCAnonStoreyBe.shaderName.StartsWith("Mobile/"))
return PerformanceChecks.FormattedTextContent("Shader might be expensive on this platform. Consider switching to a simpler shader; look under Mobile shaders.");
// ISSUE: reference to a compiler-generated field
if (materialCAnonStoreyBe.shaderName.Contains("VertexLit") && mat.HasProperty("_Emission"))
{
Color color = mat.GetColor("_Emission");
if ((double) color.r >= 0.5 && (double) color.g >= 0.5 && (double) color.b >= 0.5)
return PerformanceChecks.FormattedTextContent("Looks like you're using VertexLit shader to simulate an unlit object (white emissive). Use one of Unlit shaders instead for performance.");
}
if (mat.HasProperty("_BumpMap") && (UnityEngine.Object) mat.GetTexture("_BumpMap") == (UnityEngine.Object) null)
return PerformanceChecks.FormattedTextContent("Normal mapped shader without a normal map. Consider using a non-normal mapped shader for performance.");
}
return (string) null;
}
示例4: GetPreviewType
private static MaterialEditor.PreviewType GetPreviewType(Material mat)
{
if (mat == null)
{
return MaterialEditor.PreviewType.Mesh;
}
string a = mat.GetTag("PreviewType", false, string.Empty).ToLower();
if (a == "plane")
{
return MaterialEditor.PreviewType.Plane;
}
if (a == "skybox")
{
return MaterialEditor.PreviewType.Skybox;
}
if (mat.shader != null && mat.shader.name.Contains("Skybox"))
{
return MaterialEditor.PreviewType.Skybox;
}
return MaterialEditor.PreviewType.Mesh;
}
示例5: OnInspectorGUI
public override void OnInspectorGUI()
{
if (isVisible == false)
return;
targetMaterial = target as Material;
keyWords = targetMaterial.shaderKeywords;
float controlSize = 64;
EditorGUIUtility.LookLikeControls(Screen.width - controlSize - 20);
bFParameters = EditorGUILayout.Foldout(bFParameters, "Fragmentum Parameters");
if (bFParameters)
{
GUILayout.Space(5);
/////////////////////////////////////////////////////////////////////////////////
SetTexture("_FragTex", TextureProperty("_FragTex", " Fragment Texture(R)", ShaderUtil.ShaderPropertyTexDim.TexDim2D));
EditorGUILayout.BeginHorizontal();
SetFloat("_FragTexStrength", RangeProperty("_FragTexStrength", " Fragment Texture Strength [" + GetFloat("_FragTexStrength", out hasMixedValue).ToString("F3") + "]", 0.0f, 1.0f));
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
SetFloat("_FragPow", RangeProperty("_FragPow", " Fragment Area Pow [" + GetFloat("_FragPow", out hasMixedValue).ToString("F3") + "]", 1.0f, 10.0f));
EditorGUILayout.EndHorizontal();
SetFloat("_DisAmount", FloatProperty("_DisAmount", " Displace Amount"));
SetFloat("_FragmentScale", FloatProperty("_FragmentScale", " Fragment Scale"));
//Lock
if (keyWords.Contains("V_FR_ACTIVATOR_NONE") == false)
{
bool bLock = false;
if (targetMaterial.GetFloat("_Lock") == 1)
bLock = true;
bLock = EditorGUILayout.Toggle(" Lock Displace", bLock);
targetMaterial.SetFloat("_Lock", bLock ? 1 : 0);
if (keyWords.Contains("V_FR_ACTIVATOR_PLANE"))
{
SetFloat("_DistanceToPlane", FloatProperty("_DistanceToPlane", " Distance To Activator"));
}
}
//Rotation
//Removed
if (targetMaterial.GetTag("FragmentumTag", false).Contains("_DIS"))
{
SetTexture("_DissolveTex", TextureProperty("_DissolveTex", " Dissolve Texture(R)", ShaderUtil.ShaderPropertyTexDim.TexDim2D));
EditorGUILayout.BeginHorizontal();
SetFloat("_DissolveAmount", RangeProperty("_DissolveAmount", " Dissolve Amount [" + GetFloat("_DissolveAmount", out hasMixedValue).ToString("F3") + "]", 0.0f, 1.0f));
EditorGUILayout.EndHorizontal();
}
GUILayout.Space(6);
//Noise
//Removed
//Additional force
//Removed
//CS0414: disable
if (hasMixedValue){}
}
CommonParameters();
}
示例6: GetPreviewType
private static PreviewType GetPreviewType(Material mat)
{
if (mat != null)
{
switch (mat.GetTag("PreviewType", false, string.Empty).ToLower())
{
case "plane":
return PreviewType.Plane;
case "skybox":
return PreviewType.Skybox;
}
if ((mat.shader != null) && mat.shader.name.Contains("Skybox"))
{
return PreviewType.Skybox;
}
}
return PreviewType.Mesh;
}
示例7: ValveToStandardSingleMaterial
//---------------------------------------------------------------------------------------------------------------------------------------------------
private static bool ValveToStandardSingleMaterial( Material m, Shader destShaderStandard, Shader destShaderStandardSpecular )
{
if ( m.shader.name.Equals( "Valve/vr_standard" ) )
{
if ( ( m.GetTag( "OriginalShader", true ) != null ) && ( m.GetTag( "OriginalShader", true ).Length > 0 ) )
{
Debug.Log( " Converting from \"" + m.shader.name + "\"-->\"" + m.GetTag( "OriginalShader", true ) + "\": " + m.name + "\n" );
m.shader = Shader.Find( m.GetTag( "OriginalShader", true ) );
return true;
}
else if ( m.GetInt( "_SpecularMode" ) == 2 )
{
// Metallic specular
Debug.Log( " Converting from \"" + m.shader.name + "\"-->\"" + destShaderStandard.name + "\": " + m.name + "\n" );
m.shader = destShaderStandard;
return true;
}
else
{
// Regular specular
Debug.Log( " Converting from \"" + m.shader.name + "\"-->\"" + destShaderStandardSpecular.name + "\": " + m.name + "\n" );
m.shader = destShaderStandardSpecular;
return true;
}
}
return false;
}