| | |
| | | m_Offset: {x: 0, y: 0} |
| | | m_Floats: |
| | | - _BumpScale: 1 |
| | | - _ChangeTime: 0 |
| | | - _Cutoff: 0.5 |
| | | - _DetailNormalMapScale: 1 |
| | | - _DstBlend: 0 |
| | |
| | | - _HorizontalAmount: 4 |
| | | - _Metallic: 0 |
| | | - _Mode: 0 |
| | | - _MyTime: 0 |
| | | - _OcclusionStrength: 1 |
| | | - _Parallax: 0.02 |
| | | - _SmoothnessTextureChannel: 0 |
| | |
| | | m_Offset: {x: 0, y: 0} |
| | | m_Floats: |
| | | - _BumpScale: 1 |
| | | - _ChangeTime: 0 |
| | | - _Cutoff: 0.5 |
| | | - _DetailNormalMapScale: 1 |
| | | - _DstBlend: 0 |
| | |
| | | - _HorizontalAmount: 4 |
| | | - _Metallic: 0 |
| | | - _Mode: 0 |
| | | - _MyTime: 0 |
| | | - _OcclusionStrength: 1 |
| | | - _Parallax: 0.02 |
| | | - _SmoothnessTextureChannel: 0 |
| | | - _SpecularHighlights: 1 |
| | | - _Speed: 10 |
| | | - _Speed: 8 |
| | | - _SrcBlend: 1 |
| | | - _UVSec: 0 |
| | | - _VerticalAmount: 1 |
| | |
| | | m_Offset: {x: 0, y: 0} |
| | | m_Floats: |
| | | - _BumpScale: 1 |
| | | - _ChangeTime: 0 |
| | | - _Cutoff: 0.5 |
| | | - _DetailNormalMapScale: 1 |
| | | - _DstBlend: 0 |
| | |
| | | - _Parallax: 0.02 |
| | | - _SmoothnessTextureChannel: 0 |
| | | - _SpecularHighlights: 1 |
| | | - _Speed: 10 |
| | | - _Speed: 8 |
| | | - _SrcBlend: 1 |
| | | - _UVSec: 0 |
| | | - _VerticalAmount: 1 |
| | |
| | | m_Offset: {x: 0, y: 0} |
| | | m_Floats: |
| | | - _BumpScale: 1 |
| | | - _ChangeTime: 0 |
| | | - _Cutoff: 0.5 |
| | | - _DetailNormalMapScale: 1 |
| | | - _DstBlend: 0 |
| | |
| | | - _Parallax: 0.02 |
| | | - _SmoothnessTextureChannel: 0 |
| | | - _SpecularHighlights: 1 |
| | | - _Speed: 10 |
| | | - _Speed: 8 |
| | | - _SrcBlend: 1 |
| | | - _UVSec: 0 |
| | | - _VerticalAmount: 1 |
| | |
| | | m_Offset: {x: 0, y: 0} |
| | | m_Floats: |
| | | - _BumpScale: 1 |
| | | - _ChangeTime: 0 |
| | | - _Cutoff: 0.5 |
| | | - _DetailNormalMapScale: 1 |
| | | - _DstBlend: 0 |
| | |
| | | - _Parallax: 0.02 |
| | | - _SmoothnessTextureChannel: 0 |
| | | - _SpecularHighlights: 1 |
| | | - _Speed: 10 |
| | | - _Speed: 8 |
| | | - _SrcBlend: 1 |
| | | - _UVSec: 0 |
| | | - _VerticalAmount: 1 |
| | |
| | | _HorizontalAmount("Horizontal Amount",Float) = 8 |
| | | _VerticalAmount("Vertical Amount",Float) = 8 |
| | | _Speed("Speed",Range(1,150)) = 30 |
| | | _ChangeTime("ChangeTime",Float) = 0 |
| | | |
| | | } |
| | | SubShader |
| | | { |
| | |
| | | Blend SrcAlpha OneMinusSrcAlpha |
| | | |
| | | CGPROGRAM |
| | | |
| | | #pragma vertex vert |
| | | #pragma fragment frag |
| | | // 两条非常重要的编译指令 |
| | | #pragma vertex vert// 定点着色器 |
| | | #pragma fragment frag// 片元着色器 |
| | | #include "Lighting.cginc" |
| | | |
| | | fixed4 _Color; |
| | |
| | | float _HorizontalAmount; |
| | | float _VerticalAmount; |
| | | float _Speed; |
| | | float _ChangeTime; |
| | | |
| | | |
| | | struct a2v |
| | | { |
| | |
| | | |
| | | fixed4 frag(v2f i) :SV_Target |
| | | { |
| | | float time = floor(_Time.y * _Speed); |
| | | float row = floor(time / _HorizontalAmount); |
| | | float column = time - row * _HorizontalAmount; |
| | | //_Time float4 Time (t/20, t, t*2, t*3), use to animate things inside the shaders. |
| | | //_SinTime float4 Sine of time: (t/8, t/4, t/2, t). |
| | | //_CosTime float4 Cosine of time: (t/8, t/4, t/2, t). |
| | | //unity_DeltaTime float4 Delta time: (dt, 1/dt, smoothDt, 1/smoothDt). |
| | | //_ProjectionParams float4 x is 1.0 (or –1.0 if currently rendering with a flipped projection matrix), y is the camera’s near plane, z is the camera’s far plane and w is 1/FarPlane. |
| | | //_ScreenParams float4 x is the current render target width in pixels, y is the current render target height in pixels, z is 1.0 + 1.0/width and w is 1.0 + 1.0/height. |
| | | //这里的 t 得到的时间单位是——秒 |
| | | |
| | | float time = floor((_Time.y - _ChangeTime) * _Speed);//对输入参数向下取整。例如 floor(float(1.3)) 返回的值为 1.0;但是 floor(float(-1.3))返回的值为-2.0。 |
| | | float row = floor(time / _HorizontalAmount);//行 |
| | | float column = time - row * _HorizontalAmount;//列 |
| | | //-- |
| | | //half2 uv = float2(i.uv.x / _HorizontalAmount, i.uv.y / _VerticalAmount); |
| | | //uv.x += column / _HorizontalAmount; |
| | |
| | | } |
| | | |
| | | private Transform mat; |
| | | private MeshRenderer myRender; |
| | | |
| | | Vector3 normalScale; |
| | | |
| | | private Vector3 fireScale = new Vector3(1.92f, 1.92f, 2.208f); |
| | |
| | | private void Awake() |
| | | { |
| | | mat = transform.Find("Cube"); |
| | | myRender = mat.GetComponent<MeshRenderer>(); |
| | | normalScale = new Vector3(1.5f, 1.5f, 1.5f); |
| | | } |
| | | |
| | |
| | | { |
| | | if (isFast && isAttack) |
| | | { |
| | | mat.GetComponent<MeshRenderer>().material.SetFloat("_Speed", 40); |
| | | myRender.material.SetFloat("_Speed", 40); |
| | | } |
| | | else |
| | | { |
| | | //还原10 |
| | | mat.GetComponent<MeshRenderer>().material.SetFloat("_Speed", 8); |
| | | myRender.material.SetFloat("_Speed", 8); |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | if (material == null) return; |
| | | |
| | | this.isAttack = isAttack; |
| | | mat.GetComponent<MeshRenderer>().material = material; |
| | | myRender.material = material; |
| | | if (isAttack) |
| | | { |
| | | if (transform.name.StartsWith("GrowUpTower") || transform.name.StartsWith("BlinkTower")) |
| | | { |
| | | float t = Mathf.Floor(Time.time); |
| | | float offect = t % 8; |
| | | myRender.material.SetFloat("_ChangeTime", Mathf.Floor(Time.time - offect)); |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | myRender.material.SetFloat("_ChangeTime", Mathf.Floor(Time.time)); |
| | | } |
| | | |
| | | //Debug.Log("当前时间Time.time:"+Time.time); |
| | | // if (transform.name.StartsWith("GrowUpTower") && mat.localPosition != fireOffectp) |
| | | // { |
| | | // mat.localPosition = fireOffectp; |