位置: 编程技术 - 正文

Unity——通过Shader 制作精灵动画,瀑布(unityshader)

编辑:rootadmin

推荐整理分享Unity——通过Shader 制作精灵动画,瀑布(unityshader),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:unityshader,unityshader,unity-chan,unity如何用,unity通过tag查找物体,unity如何用,unity通过tag查找物体,unityshader,内容如对您有帮助,希望把文章链接给更多的朋友!

//精灵动画

Shader "zhaoguanghui/spriteAction" {

Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _TexWidth ("Sheet Width", float) = 0.0 _CellAmount ("Cell Amount", float) = 0.0 _Speed ("Speed", Range(0., )) = .0 } SubShader { Tags { "RenderType"="Opaque" } LOD CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; float _TexWidth; float _CellAmount; fixed _Speed; struct Input { float2 uv_MainTex; }; void surf (Input IN, inout SurfaceOutputStandard o) { float2 spriteUV = IN.uv_MainTex; float cellPixelWidth = _TexWidth/_CellAmount; float cellUVPercentage = cellPixelWidth/_TexWidth; float timeVal = fmod(_Time.y * _Speed, _CellAmount); timeVal = ceil(timeVal); float xValue = spriteUV.x; xValue &#;= cellUVPercentage * timeVal * _CellAmount; xValue *= cellUVPercentage; spriteUV = float2(xValue, spriteUV.y); half4 c = tex2D (_MainTex, spriteUV); o.Albedo = c.rgb; o.Alpha = c.a; } ENDCG } FallBack "Diffuse"Unity——通过Shader 制作精灵动画,瀑布(unityshader)

}

//瀑布

Shader "zhaoguanghui/ControlUV" { Properties { _MainTint ("Diffuse Tint", Color) = (1,1,1,1) _MainTex ("Base (RGB)", 2D) = "white" {} _ScrollXSpeed ("X Scroll Speed", Range(0,)) = 2 _ScrollYSpeed ("Y Scroll Speed", Range(0,)) = 2 } SubShader { Tags { "RenderType"="Opaque" } LOD CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 fixed4 _MainTint; fixed _ScrollXSpeed; fixed _ScrollYSpeed; sampler2D _MainTex; struct Input { float2 uv_MainTex; }; void surf (Input IN, inout SurfaceOutputStandard o) { fixed2 scrolledUV = IN.uv_MainTex; fixed xScrollValue = _ScrollXSpeed * _Time; fixed yScrollValue = _ScrollYSpeed * _Time; scrolledUV &#;= fixed2(xScrollValue, yScrollValue); half4 c = tex2D (_MainTex, scrolledUV); o.Albedo = c.rgb * _MainTint; o.Alpha = c.a; } ENDCG } FallBack "Diffuse"}

Unity 编辑器下控制播放Animator 在Unity编辑器的Scene视图进行控制播放Animator,可以借助方法StartPlayback、StopPlayback、StartRecording和StopRecording,具体可以参照以下例子:创建一个带Controller

unity 写批量打包工具时遇到的一个问题 上一篇文章解决了打出来的xcode工程不能append的问题(其实这个问题也解决了)。但是根据一些渠道要求是需要替换游戏Icon和SplashImage的,而defaultIcon和M

NullReferenceException: Object reference not set to an instance of an object 初学unity,遇到问题总是忙来忙去半天找不到解决方法,今天又遇到一个比较坑的问题,记录一下。。voidUpdate(){//KeyCode1:if(Input.GetKeyDown(KeyCode.X)){getIdShow(

本文链接地址:https://www.jiuchutong.com/biancheng/381467.html 转载请保留说明!

上一篇:Unity中Quaternion的含义及其使用(unity中ngui)

下一篇:Unity 编辑器下控制播放Animator(unity 控件)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络