本文整理汇总了C#中UnityEditor.MaterialProperty类的典型用法代码示例。如果您正苦于以下问题:C# MaterialProperty类的具体用法?C# MaterialProperty怎么用?C# MaterialProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaterialProperty类属于UnityEditor命名空间,在下文中一共展示了MaterialProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnGUI
public void OnGUI(ref Rect position, MaterialProperty prop, string label, MaterialEditor editor)
{
float num = position.height;
position.height = 0f;
if (this.m_DecoratorDrawers != null)
{
foreach (MaterialPropertyDrawer current in this.m_DecoratorDrawers)
{
position.height = current.GetPropertyHeight(prop, label, editor);
float labelWidth = EditorGUIUtility.labelWidth;
float fieldWidth = EditorGUIUtility.fieldWidth;
current.OnGUI(position, prop, label, editor);
EditorGUIUtility.labelWidth = labelWidth;
EditorGUIUtility.fieldWidth = fieldWidth;
position.y += position.height;
num -= position.height;
}
}
position.height = num;
if (this.m_PropertyDrawer != null)
{
float labelWidth = EditorGUIUtility.labelWidth;
float fieldWidth = EditorGUIUtility.fieldWidth;
this.m_PropertyDrawer.OnGUI(position, prop, label, editor);
EditorGUIUtility.labelWidth = labelWidth;
EditorGUIUtility.fieldWidth = fieldWidth;
}
}
示例2: Apply
public override void Apply(MaterialProperty prop)
{
base.Apply(prop);
if (!MaterialToggleDrawer.IsPropertyTypeSuitable(prop) || prop.hasMixedValue)
return;
this.SetKeyword(prop, (double) Math.Abs(prop.floatValue) > 1.0 / 1000.0);
}
示例3: OnGUI
override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
if (!checkVisible (editor)) return;
Color col = GUI.contentColor;
Color bcol = GUI.backgroundColor;
GUI.contentColor = new Color(1f, 1f, 0.8f, 1f);
GUI.backgroundColor = backgroundColor;
//position.y -= 15;
Rect pos=new Rect(position);
pos.y += 3;
pos.height -= 3;
//if (visibilityProp1==null || visibilityProp1=="indent") {
// pos.height -= 10;
// pos.y += 10;
//}
if (visibilityProp1!=null) {
pos.x+=12;
pos.width-=12;
}
// pos.height = 17;
EditorGUI.HelpBox(pos, (foldoutFlag ? " ":"")+label, MessageType.None);
if (foldoutFlag) {
Rect fpos = new Rect(pos);
fpos.x += 15;
fpos.y += 1;
bool state = EditorGUI.Foldout(fpos, prop.floatValue==1, "", true);
prop.floatValue = state ? 1 : 0;
}
GUI.contentColor = col;
GUI.backgroundColor = bcol;
}
示例4: FindProperties
public void FindProperties(MaterialProperty[] props)
{
blendMode = FindProperty("_Mode", props);
albedoMap = FindProperty("_MainTex", props);
albedoColor = FindProperty("_Color", props);
alphaCutoff = FindProperty("_Cutoff", props);
specularMap = FindProperty("_SpecGlossMap", props, false);
specularColor = FindProperty("_SpecColor", props, false);
metallicMap = FindProperty("_MetallicGlossMap", props, false);
metallic = FindProperty("_Metallic", props, false);
if (specularMap != null && specularColor != null)
m_WorkflowMode = WorkflowMode.Specular;
else if (metallicMap != null && metallic != null)
m_WorkflowMode = WorkflowMode.Metallic;
else
m_WorkflowMode = WorkflowMode.Dielectric;
smoothness = FindProperty("_Glossiness", props);
bumpScale = FindProperty("_BumpScale", props);
bumpMap = FindProperty("_BumpMap", props);
heigtMapScale = FindProperty("_Parallax", props);
heightMap = FindProperty("_ParallaxMap", props);
occlusionStrength = FindProperty("_OcclusionStrength", props);
occlusionMap = FindProperty("_OcclusionMap", props);
emissionScaleUI = FindProperty("_EmissionScaleUI", props);
emissionColorUI = FindProperty("_EmissionColorUI", props);
emissionColorForRendering = FindProperty("_EmissionColor", props);
emissionMap = FindProperty("_EmissionMap", props);
detailMask = FindProperty("_DetailMask", props);
detailAlbedoMap = FindProperty("_DetailAlbedoMap", props);
detailNormalMapScale = FindProperty("_DetailNormalMapScale", props);
detailNormalMap = FindProperty("_DetailNormalMap", props);
uvSetSecondary = FindProperty("_UVSec", props);
vertexColor = FindProperty("_IntensityVC", props);
}
示例5: FindProperties
public static int FindProperties(ShaderGUIBase _inst, MaterialProperty[] _properties)
{
int _cnt = 0;
var _flags = System.Reflection.BindingFlags.Instance
| System.Reflection.BindingFlags.NonPublic
| System.Reflection.BindingFlags.Public;
_inst.m_Keywords.Clear ();
foreach (var _field in _inst.GetType ().GetFields (_flags))
{
foreach (var _attr in _field.GetCustomAttributes (true))
{
var _propAttr = _attr as MaterialPropertyAttribute;
if (null != _propAttr && _field.FieldType == typeof(MaterialProperty))
{
var _prop = FindProperty (_propAttr.Name, _properties);
if (null == _prop)
{
Log.E ("Material Property {0} not found!", _propAttr.Name);
continue;
}
var _keyword = _propAttr.Keyword;
if (null != _keyword)
_inst.m_Keywords.Add (_prop.name, _keyword);
_field.SetValue (_inst, _prop);
++_cnt;
}
}
}
return _cnt;
}
示例6: ApplyMaterialModificationToAnimationRecording
public static bool ApplyMaterialModificationToAnimationRecording(MaterialProperty materialProp, int changedMask, Renderer target, object oldValue)
{
switch (materialProp.type)
{
case MaterialProperty.PropType.Color:
SetupMaterialPropertyBlock(materialProp, changedMask, target);
ApplyMaterialModificationToAnimationRecording(materialProp, target, (Color) oldValue);
return true;
case MaterialProperty.PropType.Vector:
SetupMaterialPropertyBlock(materialProp, changedMask, target);
ApplyMaterialModificationToAnimationRecording(materialProp, target, (Color) ((Vector4) oldValue));
return true;
case MaterialProperty.PropType.Float:
case MaterialProperty.PropType.Range:
SetupMaterialPropertyBlock(materialProp, changedMask, target);
ApplyMaterialModificationToAnimationRecording(materialProp, target, (float) oldValue);
return true;
case MaterialProperty.PropType.Texture:
{
if (!MaterialProperty.IsTextureOffsetAndScaleChangedMask(changedMask))
{
return false;
}
string name = materialProp.name + "_ST";
SetupMaterialPropertyBlock(materialProp, changedMask, target);
ApplyMaterialModificationToAnimationRecording(name, target, (Vector4) oldValue);
return true;
}
}
return false;
}
示例7: OnGUI
public void OnGUI(ref Rect position, MaterialProperty prop, string label, MaterialEditor editor)
{
float height = position.height;
position.height = 0.0f;
if (this.m_DecoratorDrawers != null)
{
using (List<MaterialPropertyDrawer>.Enumerator enumerator = this.m_DecoratorDrawers.GetEnumerator())
{
while (enumerator.MoveNext())
{
MaterialPropertyDrawer current = enumerator.Current;
position.height = current.GetPropertyHeight(prop, label, editor);
float labelWidth = EditorGUIUtility.labelWidth;
float fieldWidth = EditorGUIUtility.fieldWidth;
current.OnGUI(position, prop, label, editor);
EditorGUIUtility.labelWidth = labelWidth;
EditorGUIUtility.fieldWidth = fieldWidth;
position.y += position.height;
height -= position.height;
}
}
}
position.height = height;
if (this.m_PropertyDrawer == null)
return;
float labelWidth1 = EditorGUIUtility.labelWidth;
float fieldWidth1 = EditorGUIUtility.fieldWidth;
this.m_PropertyDrawer.OnGUI(position, prop, label, editor);
EditorGUIUtility.labelWidth = labelWidth1;
EditorGUIUtility.fieldWidth = fieldWidth1;
}
示例8: FindProperties
public void FindProperties(MaterialProperty[] props)
{
this.blendMode = ShaderGUI.FindProperty("_Mode", props);
this.albedoMap = ShaderGUI.FindProperty("_MainTex", props);
this.albedoColor = ShaderGUI.FindProperty("_Color", props);
this.alphaCutoff = ShaderGUI.FindProperty("_Cutoff", props);
this.specularMap = ShaderGUI.FindProperty("_SpecGlossMap", props, false);
this.specularColor = ShaderGUI.FindProperty("_SpecColor", props, false);
this.metallicMap = ShaderGUI.FindProperty("_MetallicGlossMap", props, false);
this.metallic = ShaderGUI.FindProperty("_Metallic", props, false);
this.m_WorkflowMode = this.specularMap == null || this.specularColor == null ? (this.metallicMap == null || this.metallic == null ? StandardShaderGUI.WorkflowMode.Dielectric : StandardShaderGUI.WorkflowMode.Metallic) : StandardShaderGUI.WorkflowMode.Specular;
this.smoothness = ShaderGUI.FindProperty("_Glossiness", props);
this.bumpScale = ShaderGUI.FindProperty("_BumpScale", props);
this.bumpMap = ShaderGUI.FindProperty("_BumpMap", props);
this.heigtMapScale = ShaderGUI.FindProperty("_Parallax", props);
this.heightMap = ShaderGUI.FindProperty("_ParallaxMap", props);
this.occlusionStrength = ShaderGUI.FindProperty("_OcclusionStrength", props);
this.occlusionMap = ShaderGUI.FindProperty("_OcclusionMap", props);
this.emissionColorForRendering = ShaderGUI.FindProperty("_EmissionColor", props);
this.emissionMap = ShaderGUI.FindProperty("_EmissionMap", props);
this.detailMask = ShaderGUI.FindProperty("_DetailMask", props);
this.detailAlbedoMap = ShaderGUI.FindProperty("_DetailAlbedoMap", props);
this.detailNormalMapScale = ShaderGUI.FindProperty("_DetailNormalMapScale", props);
this.detailNormalMap = ShaderGUI.FindProperty("_DetailNormalMap", props);
this.uvSetSecondary = ShaderGUI.FindProperty("_UVSec", props);
}
示例9: FindProperties
public void FindProperties (MaterialProperty[] props)
{
cullMode = FindProperty ("_CullMode", props, false);
albedoMap = FindProperty ("_MainTex", props);
albedoColor = FindProperty ("_Color", props);
specularMap = FindProperty ("_SpecGlossMap", props, false);
specularColor = FindProperty ("_SpecColor", props, false);
metallicMap = FindProperty ("_MetallicGlossMap", props, false);
metallic = FindProperty ("_Metallic", props, false);
if (specularMap != null && specularColor != null)
m_WorkflowMode = WorkflowMode.Specular;
else if (metallicMap != null && metallic != null)
m_WorkflowMode = WorkflowMode.Metallic;
else
m_WorkflowMode = WorkflowMode.Dielectric;
smoothness = FindProperty ("_Glossiness", props);
smoothnessTweak1 = FindProperty ("_SmoothnessTweak1", props, false);
smoothnessTweak2 = FindProperty ("_SmoothnessTweak2", props, false);
smoothnessTweaks = FindProperty ("_SmoothnessTweaks", props, false);
specularMapColorTweak = FindProperty ("_SpecularMapColorTweak", props, false);
bumpScale = FindProperty ("_BumpScale", props);
bumpMap = FindProperty ("_BumpMap", props);
orthoNormalize = FindProperty ("_Orthonormalize", props, false);
occlusionStrength = FindProperty ("_OcclusionStrength", props);
occlusionMap = FindProperty ("_OcclusionMap", props);
detailMask = FindProperty ("_DetailMask", props);
detailAlbedoMap = FindProperty ("_DetailAlbedoMap", props);
detailNormalMapScale = FindProperty ("_DetailNormalMapScale", props);
detailNormalMap = FindProperty ("_DetailNormalMap", props);
uvSetSecondary = FindProperty ("_UVSec", props);
smoothnessInAlbedo = FindProperty ("_SmoothnessInAlbedo", props, false);
}
示例10: OnGUI
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
base.OnGUI(materialEditor, props);
materialEditor.LightmapEmissionProperty(0);
foreach (Material target in materialEditor.targets)
target.globalIlluminationFlags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
}
示例11: SetupMaterialPropertyBlock
public static void SetupMaterialPropertyBlock(MaterialProperty materialProp, int changedMask, Renderer target)
{
MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
target.GetPropertyBlock(materialPropertyBlock);
materialProp.WriteToMaterialPropertyBlock(materialPropertyBlock, changedMask);
target.SetPropertyBlock(materialPropertyBlock);
}
示例12: OnGUI
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
FindProperties(properties);
if (ShaderPropertiesGUI(materialEditor) || _initial)
foreach (Material m in materialEditor.targets)
UpdateMaterial(m);
_initial = false;
}
示例13: GetPropertyHeight
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
if (prop.type != MaterialProperty.PropType.Range)
{
return 40f;
}
return base.GetPropertyHeight(prop, label, editor);
}
示例14: Vector3Property
void Vector3Property(MaterialEditor materialEditor, MaterialProperty prop, string label)
{
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = prop.hasMixedValue;
var newValue = EditorGUILayout.Vector3Field(label, prop.vectorValue);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck()) prop.vectorValue = newValue;
}
示例15: OnGUI
public override void OnGUI(MaterialEditor _materialEditor, MaterialProperty[] _properties)
{
FindProperties(this, _properties);
DoGeneral(_materialEditor);
DoNormalMap(_materialEditor);
DoRim(_materialEditor);
}