• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MaterialProperty类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MaterialProperty的典型用法代码示例。如果您正苦于以下问题:C# MaterialProperty类的具体用法?C# MaterialProperty怎么用?C# MaterialProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MaterialProperty类属于命名空间,在下文中一共展示了MaterialProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
                    }
                }
            }
        }
开发者ID:dkushner,项目名称:Assimp-Net,代码行数:35,代码来源:Material.cs


示例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();
	}
开发者ID:keyward,项目名称:EnemyOfMyEnemy,代码行数:35,代码来源:LayerInspector.cs


示例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);
        }
    }
开发者ID:Okacz,项目名称:LQRepo2,代码行数:31,代码来源:TerrainSurfaceGUI.cs


示例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;
        }
    }
开发者ID:jharger,项目名称:globalgamejam2016,代码行数:25,代码来源:AlloyFieldDrawerFactory.cs


示例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();
		    }
        }

    }
开发者ID:Quantarium-Studios,项目名称:FLARE_Prototype,代码行数:32,代码来源:RTP_EnumDrawer.cs


示例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;
 }
开发者ID:mqmtech,项目名称:ProceduralPlanets,代码行数:7,代码来源:MaterialGenerator.cs


示例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;
    }
开发者ID:Quantarium-Studios,项目名称:FLARE_Prototype,代码行数:25,代码来源:RTP_EndAreaDecorator.cs


示例8: OnGUI

 public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
 {
     if (GUILayout.Button("Edit"))
     {
         EditorWindow.GetWindow<MaterialNodeEditor>();
     }
 }
开发者ID:moe-ped,项目名称:SolidTextures,代码行数:7,代码来源:FractalMaterialEditor.cs


示例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");
      }
   }
开发者ID:ArieLeo,项目名称:VertexPaint,代码行数:57,代码来源:SplatMapShaderGUI.cs


示例10: GetFieldDrawer

    public static AlloyFieldDrawer GetFieldDrawer(AlloyInspectorBase editor, MaterialProperty prop) {
        AlloyFieldParser parser = GetFieldParser(prop);

        if (parser != null) {
            return parser.GetDrawer(editor);
        }

        return null;
    }
开发者ID:jharger,项目名称:globalgamejam2016,代码行数:9,代码来源:AlloyFieldDrawerFactory.cs


示例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;
    }
开发者ID:yyzreal,项目名称:TriplanarPBS,代码行数:10,代码来源:TriplanarPBSGUI.cs


示例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);
 }
开发者ID:moe-ped,项目名称:SolidTextures,代码行数:11,代码来源:FractalMaterialPreEditor.cs


示例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);
	}
开发者ID:yyzreal,项目名称:TriplanarPBS,代码行数:11,代码来源:TriplanarPBSGUI.cs


示例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;
	}
开发者ID:Quantarium-Studios,项目名称:FLARE_Prototype,代码行数:11,代码来源:FoldoutDrawer.cs


示例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();
		}
	}
开发者ID:Quantarium-Studios,项目名称:FLARE_Prototype,代码行数:13,代码来源:WarningInfoDrawer.cs


示例16: Apply

	override public void Apply(MaterialProperty prop) {
		if (myEditor!=null) {
			Material mat=myEditor.target as Material;
			if (prop.floatValue==0) {
				mat.DisableKeyword(myKeyword+"_ON");
				mat.EnableKeyword(myKeyword+"_OFF");
			} else {
				mat.DisableKeyword(myKeyword+"_OFF");
				mat.EnableKeyword(myKeyword+"_ON");
			}
		}

	}
开发者ID:Quantarium-Studios,项目名称:FLARE_Prototype,代码行数:13,代码来源:PropBlockKeywordDrawer.cs


示例17: FindProperties

    public void FindProperties(MaterialProperty[] props)
    {
        blendMask = FindProperty ("_Mask", props);

        albedoMap = FindProperty ("_MainTex", props);
        albedoMap2 = FindProperty ("_MainTex2", props);

        specularMap = FindProperty ("_SpecGlossMap", props);
        specularMap2 = FindProperty ("_SpecGlossMap2", props);

        bumpMap = FindProperty ("_NormalMap", props);
        bumpMap2 = FindProperty ("_NormalMap2", props);
    }
开发者ID:Okacz,项目名称:LQRepo2,代码行数:13,代码来源:TerrainSurfaceGUI.cs


示例18: GetPropertyHeight

 override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (editor is RTP_CustomShaderGUI)
     {
         RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
         if (customEditor.showFlag)
         {
             return 20;
         }
         return -2;
     }
     return 0;
 }
开发者ID:Quantarium-Studios,项目名称:FLARE_Prototype,代码行数:13,代码来源:RTP_BlockInfoDrawer.cs


示例19: OnGUI

    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_HeaderDecorator");

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag)
            {
                customEditor.nextLabelWidth = nextLabelWidth;
            }
        }
    }
开发者ID:Quantarium-Studios,项目名称:FLARE_Prototype,代码行数:14,代码来源:RTP_LabelWidthDecorator.cs


示例20: OnGUI

    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag)
            {
                Rect rect = GUILayoutUtility.GetLastRect();
                rect.width = Mathf.Min(rect.width, EditorGUIUtility.labelWidth);
                EditorGUI.LabelField(rect, new GUIContent("", toolTip));
            }
        }
    }
开发者ID:Quantarium-Studios,项目名称:FLARE_Prototype,代码行数:14,代码来源:RTP_TooltipDecorator.cs



注:本文中的MaterialProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MaterialType类代码示例发布时间:2022-05-24
下一篇:
C# Material类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap