Unity mobile development skillfully uses textures to make scrolling backgrounds

Source: Internet
Author: User

Skillfully use textures to make scrolling backgrounds

The main points of knowledge of this study are as follows:
1. How to create a scrolling background.
You can achieve this effect by using the material ball to keep shifting the texture.
2. The difference between time and deltatime "Dog planing Learning Net"
Time.time is the time that represents the game from start to present, and is a growth value.
Time.deltatime is a fixed value that represents the time interval between frames and frames on a machine.

The way to use this is to create a material ball, paste the background we want, have the panel attach the material ball, adjust the camera position, and hang the script on the panel we created earlier.

using Unityengine;

using System.Collections;

Public class Scollerbg:monobehaviour {

Public float xspeed=0.1f;

Public float yspeed=0.1f;

Public float x_scoller=0.1f;

Public float y_scoller=0.1f;

void Update () {

X_scoller = Time.time * xspeed; //From the beginning of the game to the present time

Y_scoller = Time.time * yspeed; //deiltetime is the time between 2 frames

//"_maintex" is the main diffuse texture and can also be accessed through the Maintextureoffset property

Renderer.material.SetTextureOffset ("_maintex", new Vector2 (x_scoller,0));

}

}

Unity mobile development skillfully uses textures to make scrolling backgrounds

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.