首页 > 编程语言 > 详细

Unity3d 编辑器中 Shader 属性导出

时间:2014-10-30 14:49:43      阅读:430      评论:0      收藏:0      [点我收藏+]

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

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 )
		{
		}
	}
}

  

Unity3d 编辑器中 Shader 属性导出

原文:http://www.cnblogs.com/tary-hit/p/4062417.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!