本文整理汇总了C#中UnityEngine.Material.GetMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# Material.GetMatrix方法的具体用法?C# Material.GetMatrix怎么用?C# Material.GetMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Material
的用法示例。
在下文中一共展示了Material.GetMatrix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: GetShaderProperties
public List<MaterialProperty> GetShaderProperties(Material material)
{
if(cache.ContainsKey(material.shader.name))
return cache[material.shader.name];
var list = new List<MaterialProperty>();
foreach(var m in MaterialProperties)
{
if(material.HasProperty(m.name))
{
if(m.type == MaterialProperty.PropertyType.unknown)
{
try
{
var p = material.GetColor(m.name);
if(p != transparent)
list.Add( new MaterialProperty { name = m.name, type = MaterialProperty.PropertyType.color });
}
catch
{
}
try
{
var p = material.GetFloat(m.name);
if(p != 0)
list.Add( new MaterialProperty { name = m.name, type = MaterialProperty.PropertyType.real });
}
catch
{
}
try
{
var p = material.GetTexture(m.name);
if(p!=null)
list.Add( new MaterialProperty { name = m.name, type = MaterialProperty.PropertyType.texture });
}
catch
{
}
try
{
var p = material.GetVector(m.name);
if(p != Vector4.zero)
list.Add( new MaterialProperty { name = m.name, type = MaterialProperty.PropertyType.vector });
}
catch
{
}
try
{
var p = material.GetMatrix(m.name);
if(p != Matrix4x4.identity)
list.Add( new MaterialProperty { name = m.name, type = MaterialProperty.PropertyType.matrix });
}
catch
{
}
try
{
var p = material.GetTextureOffset(m.name);
if(p != Vector2.zero)
list.Add( new MaterialProperty { name = m.name, type = MaterialProperty.PropertyType.textureOffset });
}
catch
{
}
try
{
var p = material.GetTextureScale(m.name);
if(p != Vector2.zero)
list.Add( new MaterialProperty { name = m.name, type = MaterialProperty.PropertyType.textureScale });
}
catch
{
}
}
else
{
list.Add(m);
}
}
}
cache[material.shader.name] = list;
return list;
}
示例3: CloneToBuffer
private void CloneToBuffer(Material mat, CommandBuffer buf)
{
foreach (KeyValuePair<object, object> field in cache)
{
object obj = field.Value;
//float
int id = (int)field.Key;
if (obj.GetType() == typeof(float))
{
float value = mat.GetFloat(id);
buf.SetGlobalFloat(id, value);
}
//Color
else if (obj.GetType() == typeof(Color))
{
Color value = mat.GetColor(id);
buf.SetGlobalColor(id, value);
}
//Color32
else if (obj.GetType() == typeof(Color32))
{
Color value = mat.GetColor(id);
buf.SetGlobalColor(id, value);
}//Vector2
else if (obj.GetType() == typeof(Vector2))
{
Vector4 value = mat.GetVector(id);
buf.SetGlobalVector(id, value);
}
//Vector3
else if (obj.GetType() == typeof(Vector3))
{
Vector4 value = mat.GetVector(id);
buf.SetGlobalVector(id, value);
}
//Vector4
else if (obj.GetType() == typeof(Vector4))
{
Vector4 value = mat.GetVector(id);
buf.SetGlobalVector(id, value);
}
//Matrix
else if (obj.GetType() == typeof(Matrix4x4))
{
Matrix4x4 value = mat.GetMatrix(id);
buf.SetGlobalMatrix(id, value);
}
}
}