Unity3d 编辑器中 Shader 属性导出_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > Unity3d 编辑器中 Shader 属性导出

Unity3d 编辑器中 Shader 属性导出

 2014/10/30 15:06:23  (soli)Tary  程序员俱乐部  我要评论(0)
  • 摘要:本例用于导出TerrainForMobile/3TexturesDiffuseSimple的shader的贴图和缩放导出protectedconststringSHADER_FILTER="TerrainForMobile/3TextureDiffuseSimple";publicvoidparse(GameObjectgo){//判空就不写了Rendererrenderer=go.renderer;Materialmat=renderer.sharedMaterial
  • 标签:

本例用于导出TerrainForMobile/3TexturesDiffuseSimple 的shader的贴图和缩放导出

class="brush:csharp;gutter:true;">protected const string SHADER_FILTER = "TerrainForMobile/3TextureDiffuseSimple";

public void parse(GameObject go)
{
	//判空就不写了
	Renderer renderer = go.renderer;
	Material mat = renderer.sharedMaterial;
	Shader shader = mat.shader;

	int count = ShaderUtil.GetPropertyCount(shader);
	
	for ( int index = 0; index < count; ++index )
	{
		ShaderUtil.ShaderPropertyType type = ShaderUtil.GetPropertyType(shader, index);
		
		string propertyName = ShaderUtil.GetPropertyName(shader, index);
		
		if ( ShaderUtil.ShaderPropertyType.TexEnv == type )
		{
			Debug.log( "ShaderPropertyName:" + propertyName );
			Texture texture = mat.GetTexture(propertyName);
			Debug.log( "ShaderPropertyName:" + texture.ToString() );
			Vector2 textureScale = mat.GetTextureScale(propertyName);
			Debug.log( "textureScale:" + textureScale.ToString() );
			Vector2 textureOffset = mat.GetTextureScale(propertyName);
			Debug.log( "textureOffset:" + textureOffset.ToString() );
			
		}
		else if ( ShaderUtil.ShaderPropertyType.Color == type )
		{
		}
	}
}

  

  • 相关文章
发表评论
用户名: 匿名