Unity background Infinite loop scrolling effect

Source: Internet
Author: User

The background infinite loop scrolling effect is as follows:

The steps are as follows:

    1. After importing the background picture, set the format of the picture, such as;

2. The image format can also be set to texture format, but wrap Mode must be repeat[repeated]; then remember to apply it. [Explanation: Wrap mode: cycle modes; line wrapping mode; wrapping mode; winding]

3. In the Hierachy view, create a new 2D object-〉sprite or an image to put the previously set sprite into texture.

4. In Project view, right-create a new shader, name it, and then modify the shader code in the editor as follows:

Shader"UNLIT/SCROLLX"{Properties {_maintex ("Base Layer (RGB)", 2D) =" White"{}// Textures_SCROLLX ("Base layer Scroll speed", Float) =1.0   // scrolling Speed_mutiplier ("Layer Mutiplier", Float) =1         //Overall Brightness} subshader {tags{"Rendertype"="Opaque" "Queue"="Geometry"} LOD -Pass {tags{"Lightmode"="Forwardbase"} cgprogram#pragmaVertex vert#pragmaFragment Frag#include"Unitycg.cginc"        structa2v {float4 vertex:position;    FLOAT2 texcoord:texcoord0;    }; structv2f {float4 pos:sv_position;    FLOAT2 uv:texcoord0;    };    Sampler2d _maintex; FLOAT4 _maintex_st;     float_scrollx;    float_mutiplier;        v2f Vert (a2v v) {v2f o; O.pos=Unityobjecttoclippos (V.vertex); O.uv.xy= Transform_tex (V.texcoord, _maintex) + frac (FLOAT2 (_SCROLLX,0.0) *_time.y);         returno; } fixed4 Frag (v2f i): sv_target {fixed4 C=tex2d (_maintex, i.uv.xy);C.rgb *=_mutiplier; returnC; } ENDCG}} FallBack"Vertexlit"}

5. Select the previous step to set up a good shader, the right mouse button to create a new material[This is the shortcut creation method, at this time to create the material used by the shader is the new shader], will need to set the scrolling background map into the texture of the material ball, such as;

  

6. Place the material ball in the material of the object created in step 2 and run it.

Of course, this is for the background is a regular graphic, as for the sector or circular, arc can only be considered separately. In the third step, you can also create rawimage, but the image and Sprite will become darker. Icon

This is not very clear ....

Unity background Infinite loop scrolling effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.