本文整理汇总了C#中UnityEngine.Material.GetFloat方法的典型用法代码示例。如果您正苦于以下问题:C# Material.GetFloat方法的具体用法?C# Material.GetFloat怎么用?C# Material.GetFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Material
的用法示例。
在下文中一共展示了Material.GetFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkSpecUsage
bool checkSpecUsage(Material mat, string label) {
if ((label.IndexOf("layer Spec+Gloss")<0) && (label.IndexOf("gloss mask")<0) && (label.IndexOf("Spec (RGB)")<0)) return true;
if (!mat.HasProperty("_DirectSpec")) return true;
if (!mat.HasProperty("_IBLSpec")) return true;
if (mat.GetFloat("_DirectSpec")==0 && mat.GetFloat("_IBLSpec")==0) return false;
return true;
}
示例2: Start
// Use this for initialization
void Start () {
heatMaterial = heat.renderer.material;
defaultStrength = heatMaterial.GetFloat("strength");
strength = defaultStrength;
defaultTransparency = heatMaterial.GetFloat("transparency");
transparency = defaultTransparency;
}
示例3: Update
void Update()
{
terrain = GetComponent<Terrain>();
tData = terrain ? terrain.terrainData : null;
tMaterial = terrain ? terrain.materialTemplate : null;
if (!terrain || !tData || !tMaterial)
return;
if(disableBasemap && !Application.isPlaying && GetComponent<Terrain>().basemapDistance != 1000000) // only reset on update in edit mode
GetComponent<Terrain>().basemapDistance = 1000000;
if (cutoutMode)
{
if (tMaterial.HasProperty("_CutoutModeHideAlpha") && tMaterial.GetFloat("_CutoutModeHideAlpha") != cutoutModeHideAlpha)
tMaterial.SetFloat("_CutoutModeHideAlpha", cutoutModeHideAlpha);
}
else
if (tMaterial.HasProperty("_CutoutModeHideAlpha") && tMaterial.GetFloat("_CutoutModeHideAlpha") != -1)
tMaterial.SetFloat("_CutoutModeHideAlpha", -1);
if (!Application.isPlaying)
ApplyTransparencyMap();
else
if (!transparencyMap && autoUpdateTransparencyMap)
{
UpdateTransparencyMap();
ApplyTransparencyMap();
}
else
ApplyTransparencyMap();
}
示例4: CopyMaterialProperties
/// <summary>
/// Copy Shader properties from source to destination material.
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static void CopyMaterialProperties(Material source, Material destination)
{
MaterialProperty[] source_prop = MaterialEditor.GetMaterialProperties(new Material[] { source });
for (int i = 0; i < source_prop.Length; i++)
{
int property_ID = Shader.PropertyToID(source_prop[i].name);
if (destination.HasProperty(property_ID))
{
//Debug.Log(source_prop[i].name + " Type:" + ShaderUtil.GetPropertyType(source.shader, i));
switch (ShaderUtil.GetPropertyType(source.shader, i))
{
case ShaderUtil.ShaderPropertyType.Color:
destination.SetColor(property_ID, source.GetColor(property_ID));
break;
case ShaderUtil.ShaderPropertyType.Float:
destination.SetFloat(property_ID, source.GetFloat(property_ID));
break;
case ShaderUtil.ShaderPropertyType.Range:
destination.SetFloat(property_ID, source.GetFloat(property_ID));
break;
case ShaderUtil.ShaderPropertyType.TexEnv:
destination.SetTexture(property_ID, source.GetTexture(property_ID));
break;
case ShaderUtil.ShaderPropertyType.Vector:
destination.SetVector(property_ID, source.GetVector(property_ID));
break;
}
}
}
}
示例5: GetFontExtent
// Function to calculate padding required for Outline Width & Dilation for proper text alignment
public static Vector4 GetFontExtent(Material material)
{
if (!material.HasProperty(ShaderUtilities.ID_GradientScale))
return Vector4.zero; // We are using an non SDF Shader.
float scaleRatioA = material.GetFloat(ID_ScaleRatio_A);
float faceDilate = material.GetFloat(ID_FaceDilate) * scaleRatioA;
float outlineThickness = material.GetFloat(ID_OutlineWidth) * scaleRatioA;
float extent = Mathf.Min(1, faceDilate + outlineThickness);
extent *= material.GetFloat(ID_GradientScale);
return new Vector4(extent, extent, extent, extent);
}
示例6: AssignNewShaderToMaterial
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
{
if (material.HasProperty("_Emission"))
{
material.SetColor("_EmissionColor", material.GetColor("_Emission"));
}
base.AssignNewShaderToMaterial(material, oldShader, newShader);
if ((oldShader == null) || !oldShader.name.Contains("Legacy Shaders/"))
{
SetupMaterialWithBlendMode(material, (BlendMode) ((int) material.GetFloat("_Mode")));
}
else
{
BlendMode opaque = BlendMode.Opaque;
if (oldShader.name.Contains("/Transparent/Cutout/"))
{
opaque = BlendMode.Cutout;
}
else if (oldShader.name.Contains("/Transparent/"))
{
opaque = BlendMode.Fade;
}
material.SetFloat("_Mode", (float) opaque);
Material[] mats = new Material[] { material };
this.DetermineWorkflow(MaterialEditor.GetMaterialProperties(mats));
MaterialChanged(material, this.m_WorkflowMode);
}
}
示例7: SetMaterialKeywords
public static void SetMaterialKeywords(Material material, WorkflowMode workflowMode)
{
// Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
// (MaterialProperty value might come from renderer material property block)
SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap"));
if (workflowMode == WorkflowMode.Specular && material.HasProperty("_SpecGlossMap"))
SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
else if (workflowMode == WorkflowMode.Metallic && material.HasProperty("_MetallicGlossMap"))
SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap"));
bool shouldEmissionBeEnabled = ShouldEmissionBeEnabled(material.GetColor("_EmissionColor"));
SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled);
// Setup lightmap emissive flags
MaterialGlobalIlluminationFlags flags = material.globalIlluminationFlags;
if ((flags & (MaterialGlobalIlluminationFlags.BakedEmissive | MaterialGlobalIlluminationFlags.RealtimeEmissive)) != 0)
{
flags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
if (!shouldEmissionBeEnabled)
flags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
material.globalIlluminationFlags = flags;
}
SetKeyword(material, "_VERTEXCOLOR", material.GetFloat("_IntensityVC") > 0f);
}
示例8: checkRenderingMode
void checkRenderingMode(Material mat)
{
if (mat.GetFloat ("_Mode") != 3)
{
Debug.LogError ("Make sure the fadable material has a rendering mode of Transparent");
}
}
示例9: SetFromToCurrent
public void SetFromToCurrent()
{
if (_material = material)
{
from = _material.GetFloat(propertyID);
}
}
示例10: OnRecord
public override void OnRecord()
{
if (_material = material)
{
_original = _material.GetFloat(propertyID);
}
}
示例11: GetValues
public List<StoredValue> GetValues(Material m)
{
var list = GetShaderProperties(m);
var output = new List<StoredValue>();
foreach(var p in list)
{
var o = new StoredValue { Property = p };
output.Add(o);
switch(p.type)
{
case MaterialProperty.PropertyType.color:
o.Value = m.GetColor(p.name);
break;
case MaterialProperty.PropertyType.real:
o.Value = m.GetFloat(p.name);
break;
case MaterialProperty.PropertyType.texture:
o.Value = m.GetTexture(p.name);
break;
case MaterialProperty.PropertyType.vector:
o.Value = m.GetVector(p.name);
break;
case MaterialProperty.PropertyType.textureOffset:
o.Value = m.GetTextureOffset(p.name);
break;
case MaterialProperty.PropertyType.textureScale:
o.Value = m.GetTextureScale(p.name);
break;
case MaterialProperty.PropertyType.matrix:
o.Value = m.GetMatrix(p.name);
break;
}
}
return output;
}
示例12: FromMaterial
public static SMaterial FromMaterial(Material mat)
{
if (mat == null)
return null;
Shader shader = mat.shader;
if (shader == null)
return null;
SMaterial result = new SMaterial();
result.instanceID = mat.GetInstanceID();
result.materialName = mat.name;
result.shaderName = shader.name;
ShaderProperties.Info info = ShaderPropertyHelper.GetShaderInfo(shader.name);
if (info != null){
ComposedByteStream rawData = new ComposedByteStream();
int iMax = info.propertyNames.Length;
for (int i = 0; i < iMax; i++)
{
string propName = info.propertyNames[i];
switch (info.propertyTypes[i])
{
case ShaderProperties.PropType.Color:
Color color = mat.GetColor(propName);
rawData.AddStream(new float[] { color.r, color.g, color.b, color.a });
break;
case ShaderProperties.PropType.Range:
case ShaderProperties.PropType.Float:
rawData.AddStream(new float[] { mat.GetFloat(propName) });
break;
case ShaderProperties.PropType.TexEnv:
Texture texture = mat.GetTexture(propName);
Vector2 offset = mat.GetTextureOffset(propName);
Vector2 scale = mat.GetTextureScale(propName);
rawData.AddStream(new int[] { texture != null ? texture.GetInstanceID() : -1 });
rawData.AddStream(texture != null ? texture.name : "" );
rawData.AddStream(new float[] { offset.x, offset.y });
rawData.AddStream(new float[] { scale.x, scale.y });
break;
case ShaderProperties.PropType.Vector:
Vector4 vector = mat.GetVector(propName);
rawData.AddStream(new float[] { vector.x, vector.y, vector.z, vector.w });
break;
}
}
result.rawData = rawData.Compose();
return result;
} else {
if (vBug.settings.general.debugMode)
Debug.LogError("No shader-info found @" + shader.name);
return null;
}
}
示例13: Awake
void Awake()
{
// make a private material
animatedMaterial = Object.Instantiate(Helpers.LoadResource<Material>("TrillingFastPoint")) as Material;
animatedMaterial.name = animatedMaterial.name.Replace("(Clone)", "");
tunnelDDef = animatedMaterial.GetFloat("_TunnelD");
tunnelDWarp = animatedMaterial.GetFloat("_TunnelDMax");
tunnelRDef = animatedMaterial.GetFloat("_TunnelRadius");
tunnelRWarp = animatedMaterial.GetFloat("_TunnelRadiusMax");
if (renderer != null)
renderer.sharedMaterial = animatedMaterial;
foreach(MeshRenderer mr in GetComponentsInChildren<MeshRenderer>()) {
mr.sharedMaterial = animatedMaterial;
}
}
示例14: SetToToCurrent
public void SetToToCurrent()
{
if (_material = material)
{
to = _material.GetFloat(propertyID);
}
}
示例15: Awake
void Awake ()
{
material = GetComponent<Renderer>().material;
cubemap = (Cubemap)material.GetTexture("_Cube");
rendererArray = GetComponentsInChildren<Renderer>();
rotation = material.GetFloat("_Rotation");
bookArray = GetComponentsInChildren<Book>();
}