本文整理汇总了C#中MaterialProperty类的典型用法代码示例。如果您正苦于以下问题:C# MaterialProperty类的具体用法?C# MaterialProperty怎么用?C# MaterialProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaterialProperty类属于命名空间,在下文中一共展示了MaterialProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Material
/// <summary>
/// Constructs a new Material.
/// </summary>
/// <param name="material">Unmanaged AiMaterial struct.</param>
internal Material(AiMaterial material)
{
_properties = new Dictionary<String, MaterialProperty>();
_textures = new Dictionary<int, List<TextureSlot>>();
if(material.NumProperties > 0 && material.Properties != IntPtr.Zero) {
AiMaterialProperty[] properties = MemoryHelper.MarshalArray<AiMaterialProperty>(material.Properties, (int) material.NumProperties, true);
for(int i = 0; i < properties.Length; i++) {
MaterialProperty prop = new MaterialProperty(properties[i]);
_properties.Add(prop.FullyQualifiedName, prop);
}
}
//Idea is to look at each texture type, and get the "TextureSlot" struct of each one. They're essentially stored in a dictionary where each type contains a bucket
//of textures. It seems just looping over properties will yield duplicates (no idea what the non $tex.file properties are, but they all seem to contain the same texture info).
//So hopefully doing it this way will give a nice and concise list of textures that can easily be retrieved, and all pertinent info (file path, wrap mode, etc) will be available to
//the user.
foreach(var texType in Enum.GetValues(typeof(TextureType))) {
TextureType type = (TextureType) texType;
if(type != TextureType.None) {
uint count = AssimpMethods.GetMaterialTextureCount(ref material, type);
for(uint i = 0; i < count; i++) {
List<TextureSlot> slots;
if(!_textures.TryGetValue((int) type, out slots)) {
slots = new List<TextureSlot>();
_textures.Add((int) type, slots);
}
slots.Add(AssimpMethods.GetMaterialTexture(ref material, type, i));
}
}
}
}
示例2: DrawProperty
// draws a standard material property, optionally disabled, and either compact or full-sized.
// minimal flag on texture properties means hide UV tiling.
private void DrawProperty(MaterialProperty prop, string label, string subLabel, bool disabled) {
EditorGUI.BeginDisabledGroup(disabled);
if( prop.type == MaterialProperty.PropType.Color ) {
EditorGUIUtility.labelWidth = 134;
EditorGUIUtility.fieldWidth = 84;
}
else if( prop.type == MaterialProperty.PropType.Texture ) {
EditorGUIUtility.labelWidth = 220;
EditorGUIUtility.fieldWidth = 84;
}
else {
EditorGUIUtility.labelWidth = 134;
EditorGUIUtility.fieldWidth = 84;
}
if( prop.type == MaterialProperty.PropType.Color ) {
ShaderProperty(prop, label);
}
else if( prop.type == MaterialProperty.PropType.Texture ) {
TextureProperty(prop, label);
/*if( subLabel.Length > 0 ) {
Rect r = GUILayoutUtility.GetLastRect();
r.x = EditorGUIUtility.labelWidth - 21f;
EditorGUI.BeginDisabledGroup(true);
EditorGUI.LabelField(r, subLabel);
EditorGUI.EndDisabledGroup();
}*/
GUILayout.Space(6);
} else {
ShaderProperty(prop, label);
}
EditorGUI.EndDisabledGroup();
}
示例3: OnGUI
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
FindProperties (props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
// Use default labelWidth
EditorGUIUtility.labelWidth = 0f;
// Detect any changes to the material
EditorGUI.BeginChangeCheck();
{
GUILayout.Label (Styles.material0Header, EditorStyles.boldLabel);
// Texture
materialEditor.TexturePropertySingleLine (Styles.albedo, albedoMap);
materialEditor.TexturePropertySingleLine (Styles.specular, specularMap);
materialEditor.TexturePropertySingleLine (Styles.normal, bumpMap);
materialEditor.TextureScaleOffsetProperty (albedoMap);
GUILayout.Label (Styles.maskHeader, EditorStyles.boldLabel);
materialEditor.TexturePropertySingleLine (Styles.blendMask, blendMask);
materialEditor.TextureScaleOffsetProperty (blendMask);
GUILayout.Label (Styles.material1Header, EditorStyles.boldLabel);
materialEditor.TexturePropertySingleLine (Styles.albedo, albedoMap2);
materialEditor.TexturePropertySingleLine (Styles.specular, specularMap2);
materialEditor.TexturePropertySingleLine (Styles.normal, bumpMap2);
materialEditor.TextureScaleOffsetProperty (albedoMap2);
}
}
示例4: GetFieldParser
private static AlloyFieldParser GetFieldParser(MaterialProperty prop) {
switch (prop.type) {
case MaterialProperty.PropType.Texture:
if (prop.textureDimension == MaterialProperty.TexDim.Cube) {
return new AlloyCubeParser(prop);
}
return new AlloyTextureParser(prop);
case MaterialProperty.PropType.Range:
case MaterialProperty.PropType.Float:
return new AlloyFloatParser(prop);
case MaterialProperty.PropType.Color:
return new AlloyColorParser(prop);
case MaterialProperty.PropType.Vector:
return new AlloyVectorParser(prop);
default:
Debug.LogError("No appopriate parser found to generate a drawer");
return null;
}
}
示例5: OnGUI
override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
//Debug.Log("OnGUI: " + label + " RTP_MaterialProp");
if (!parsed)
{
parsed = true;
parsedLabel = RTP_MatPropStringParser.Parse(label);
}
label = parsedLabel;
if (editor is RTP_CustomShaderGUI)
{
RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
if (customEditor.showFlag) {
EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);
EditorGUIUtility.labelWidth = 300;
EditorGUI.BeginChangeCheck();
float pval = prop.floatValue;
float nval = EditorGUI.Popup(position, label, (int)pval, props);
if (EditorGUI.EndChangeCheck())
{
prop.floatValue = nval;
}
EditorGUI.EndDisabledGroup();
}
}
}
示例6: IsMaterialValid
bool IsMaterialValid(MaterialProperty property, float radius)
{
float minRadius = Mathf.Round(property.MinRadius * _maxRadius);
float maxRadius = Mathf.Round(property.MaxRadius * _maxRadius);
radius = Mathf.Round(radius);
return radius >= minRadius && radius <= maxRadius;
}
示例7: GetPropertyHeight
override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
//Debug.Log("GetHeight: " + label + " RTP_EndAreaDecorator");
if (editor is RTP_CustomShaderGUI)
{
RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
if (customEditor.helperFlag)
{
customEditor.helperFlag = false;
return 0;
}
customEditor.helperFlag = true;
if (customEditor.showFlag)
{
EditorGUILayout.EndVertical();
if (indent)
{
// EditorGUI.indentLevel--;
EditorGUILayout.EndHorizontal();
}
}
}
return 0;
}
示例8: OnGUI
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
if (GUILayout.Button("Edit"))
{
EditorWindow.GetWindow<MaterialNodeEditor>();
}
}
示例9: DrawLayer
void DrawLayer(MaterialEditor editor, int i, MaterialProperty[] props, string[] keyWords, Workflow workflow,
bool hasGloss, bool hasSpec, bool isParallax, bool hasEmis, bool hasDistBlend)
{
EditorGUIUtility.labelWidth = 0f;
var albedoMap = FindProperty ("_Tex" + i, props);
var tint = FindProperty("_Tint" + i, props);
var normalMap = FindProperty ("_Normal" + i, props);
var smoothness = FindProperty("_Glossiness" + i, props);
var glossinessMap = FindProperty("_GlossinessTex" + i, props, false);
var metallic = FindProperty("_Metallic" + i, props, false);
var emissionTex = FindProperty("_Emissive" + i, props);
var emissionMult = FindProperty("_EmissiveMult" + i, props);
var parallax = FindProperty("_Parallax" + i, props);
var texScale = FindProperty("_TexScale" + i, props);
var specMap = FindProperty("_SpecGlossMap" + i, props, false);
var specColor = FindProperty("_SpecColor" + i, props, false);
var distUVScale = FindProperty("_DistUVScale" + i, props, false);
editor.TexturePropertySingleLine(new GUIContent("Albedo/Height"), albedoMap);
editor.ShaderProperty(tint, "Tint");
editor.TexturePropertySingleLine(new GUIContent("Normal"), normalMap);
if (workflow == Workflow.Metallic)
{
editor.TexturePropertySingleLine(new GUIContent("Metal(R)/Smoothness(A)"), glossinessMap);
}
else
{
editor.TexturePropertySingleLine(new GUIContent("Specular(RGB)/Gloss(A)"), specMap);
}
if (workflow == Workflow.Metallic && !hasGloss)
{
editor.ShaderProperty(smoothness, "Smoothness");
editor.ShaderProperty(metallic, "Metallic");
}
else if (workflow == Workflow.Specular && !hasSpec)
{
editor.ShaderProperty(smoothness, "Smoothness");
editor.ShaderProperty(specColor, "Specular Color");
}
editor.TexturePropertySingleLine(new GUIContent("Emission"), emissionTex);
editor.ShaderProperty(emissionMult, "Emissive Multiplier");
editor.ShaderProperty(texScale, "Texture Scale");
if (hasDistBlend)
{
editor.ShaderProperty(distUVScale, "Distance UV Scale");
}
if (isParallax)
{
editor.ShaderProperty(parallax, "Parallax Height");
}
if (i != 1)
{
editor.ShaderProperty(FindProperty("_Contrast"+i, props), "Interpolation Contrast");
}
}
示例10: GetFieldDrawer
public static AlloyFieldDrawer GetFieldDrawer(AlloyInspectorBase editor, MaterialProperty prop) {
AlloyFieldParser parser = GetFieldParser(prop);
if (parser != null) {
return parser.GetDrawer(editor);
}
return null;
}
示例11: OnGUI
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
FindProperties(properties);
if (ShaderPropertiesGUI(materialEditor) || _initial)
foreach (Material m in materialEditor.targets)
SetMaterialKeywords(m);
_initial = false;
}
示例12: OnGUI
//TODO: see if there is a better callback function
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
string content = File.ReadAllText(TEMPLATE_PATH);
content = content.Replace(ORIGINAL_SHADER_NAME, string.Format(SHADER_NAME_SYNTAX, materialEditor.target.name.Split(' ')[0]));
content = content.Replace(PRE_EDITOR, EDITOR);
File.WriteAllText(string.Format(OUTPUT_PATH, materialEditor.target.name.Split(' ')[0] + ".shader"), content);
AssetDatabase.ImportAsset (string.Format(RELATIVE_OUTPUT_PATH, materialEditor.target.name.Split(' ')[0] + ".shader"));
Shader shader = Shader.Find(string.Format(SHADER_NAME_SYNTAX, materialEditor.target.name));
materialEditor.SetShader(shader);
}
示例13: FindProperties
void FindProperties(MaterialProperty[] props)
{
_albedoMap = FindProperty("_MainTex", props);
_albedoColor = FindProperty("_Color", props);
_metallic = FindProperty("_Metallic", props, false);
_smoothness = FindProperty("_Glossiness", props);
_bumpMap = FindProperty("_BumpMap", props);
_occlusionStrength = FindProperty("_OcclusionStrength", props);
_occlusionMap = FindProperty("_OcclusionMap", props);
_mapScale = FindProperty("_MapScale", props);
}
示例14: GetPropertyHeight
override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) {
bool inactiveFlag=false;
if (checkVisible(editor, ref inactiveFlag)) {
if (prop.floatValue==1) {
return MaterialEditor.GetDefaultPropertyHeight(prop);
} else {
return MaterialEditor.GetDefaultPropertyHeight(prop)-5;
}
}
return -2;
}
示例15: OnGUI
override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
bool inactiveFlag = false;
//if (!checkNormalmapsUsage(editor.target as Material, label)) return;
//if (!checkIBLUsage(editor.target as Material, label)) return;
if (checkVisible (editor, ref inactiveFlag)) {
EditorGUI.BeginDisabledGroup(inactiveFlag);
position.x+=12;
position.width-=12;
EditorGUI.HelpBox(position, label, MessageType.Warning);
EditorGUI.EndDisabledGroup();
}
}