本文整理汇总了C#中UnityEditor.MaterialEditor类的典型用法代码示例。如果您正苦于以下问题:C# MaterialEditor类的具体用法?C# MaterialEditor怎么用?C# MaterialEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaterialEditor类属于UnityEditor命名空间,在下文中一共展示了MaterialEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShaderPropertiesGUI
bool ShaderPropertiesGUI(MaterialEditor materialEditor)
{
EditorGUI.BeginChangeCheck();
materialEditor.ShaderProperty(_colorMode, "Color Mode");
if (_colorMode.floatValue > 0)
{
var rect = EditorGUILayout.GetControlRect();
rect.x += EditorGUIUtility.labelWidth;
rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2 - 2;
materialEditor.ShaderProperty(rect, _color, "");
rect.x += rect.width + 4;
materialEditor.ShaderProperty(rect, _color2, "");
}
else
{
materialEditor.ShaderProperty(_color, " ");
}
EditorGUILayout.Space();
materialEditor.ShaderProperty(_metallic, "Metallic");
materialEditor.ShaderProperty(_smoothness, "Smoothness");
EditorGUILayout.Space();
materialEditor.TexturePropertySingleLine(_albedoText, _albedoMap, null);
materialEditor.TexturePropertySingleLine(_normalMapText, _normalMap, _normalMap.textureValue ? _normalScale : null);
materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue ? _occlusionStr : null);
materialEditor.TextureScaleOffsetProperty(_albedoMap);
return EditorGUI.EndChangeCheck();
}
示例2: 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;
}
示例3: ShaderPropertiesGUI
bool ShaderPropertiesGUI(MaterialEditor materialEditor)
{
EditorGUI.BeginChangeCheck();
// albedo
materialEditor.TexturePropertySingleLine(_albedoText, _mainTex, _color);
// metallic / smoothness
if (_metallicGlossMap.textureValue == null)
materialEditor.TexturePropertyTwoLines(_metallicText, _metallicGlossMap, _metallic, _smoothnessText, _glossiness);
else
materialEditor.TexturePropertySingleLine(_metallicText, _metallicGlossMap);
// normal map
materialEditor.TexturePropertySingleLine(_normalMapText, _bumpMap, _bumpMap.textureValue != null ? _bumpScale : null);
// occlusion
materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue != null ? _occlusionStrength : null);
// emission
bool hadEmissionTexture = _emissionMap.textureValue != null;
materialEditor.TexturePropertyWithHDRColor(_emissionText, _emissionMap, _emissionColor, _colorPickerHDRConfig, false);
// if texture was assigned and color was black set color to white
if (_emissionMap.textureValue != null && !hadEmissionTexture)
if (_emissionColor.colorValue.maxColorComponent <= 0)
_emissionColor.colorValue = Color.white;
return EditorGUI.EndChangeCheck();
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
}
示例7: ShaderPropertiesGUI
bool ShaderPropertiesGUI(MaterialEditor materialEditor)
{
EditorGUI.BeginChangeCheck();
materialEditor.ShaderProperty(_blendMode, "Blend Mode");
materialEditor.ShaderProperty(_colorMode, "Color Mode");
if (_colorMode.floatValue > 0)
{
var rect = EditorGUILayout.GetControlRect();
rect.x += EditorGUIUtility.labelWidth;
rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2 - 2;
materialEditor.ShaderProperty(rect, _color, "");
rect.x += rect.width + 4;
materialEditor.ShaderProperty(rect, _color2, "");
}
else
{
materialEditor.ShaderProperty(_color, " ");
}
materialEditor.ShaderProperty(_mainTex, "Texture");
return EditorGUI.EndChangeCheck();
}
示例8: OnGUI
public override void OnGUI(MaterialEditor _materialEditor, MaterialProperty[] _properties)
{
FindProperties(this, _properties);
DoGeneral(_materialEditor);
DoNormalMap(_materialEditor);
DoRim(_materialEditor);
}
示例9: 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);
}
示例10: 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;
}
示例11: GetPropertyHeight
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
if (!IsPropertyTypeSuitable(prop))
{
return 40f;
}
return base.GetPropertyHeight(prop, label, editor);
}
示例12: 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;
}
示例13: ShaderPropertiesGUI
bool ShaderPropertiesGUI(MaterialEditor materialEditor)
{
EditorGUI.BeginChangeCheck();
materialEditor.TexturePropertySingleLine(_textCubemap, _cubemap, _tint);
Vector3Property(materialEditor, _euler, "Rotation");
materialEditor.ShaderProperty(_exposure, "Exposure");
materialEditor.ShaderProperty(_saturation, "Saturation");
return EditorGUI.EndChangeCheck();
}
示例14: GetPropertyHeight
override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) {
bool inactiveFlag=false;
if (!checkSpecUsage(editor.target as Material, label)) return -2;
if (!checkEmissiveUsage(editor.target as Material, label)) return -2;
if (checkVisible(editor, ref inactiveFlag)) {
return MaterialEditor.GetDefaultPropertyHeight(prop);
}
return -2;
}
示例15: OnGUI
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
m_MaterialEditor = materialEditor;
Material material = materialEditor.target as Material;
FindProperties (material, props);
ShaderPropertiesGUI (material);
}