U3D 2d sequence Animation code

Source: Internet
Author: User

Using unityengine;using System.Collections;    public class Anisprite:monobehaviour {private float myTime = 0;    private bool Isplay = true; Anisprit. Sprite (4, 6, 0, 0, 1f), meaning: The map is a 4-column, 6-row animation diagram, the graph starts with coordinates (0,0), the total number of frames given 20 frames, frame rate 24, total time 1 seconds public bool Sprite (int columnsize,in T rowsize, float colframestart, float rowframestart, int totalframes, int framespersecond, float totaltime) {my        Time + = Time.deltatime;            if (totaltime! = 0 && myTime > totaltime) {isplay = false;            MyTime = 0;        return isplay;         } int index = (int) (Time.time * framespersecond)% Totalframes;         Vector2 size = new Vector2 (1.0f/columnsize,1.0f/rowsize);        int u = index% ColumnSize;         int v = index/columnsize;        Vector2 offset = new Vector2 ((U + colframestart) * size.x, (1.0F-SIZE.Y)-(v + rowframestart) * size.y);        Renderer.material.mainTextureScale = size; Renderer.material.mainTextureOffset = ofFset    return true; }}

U3D 2d sequence Animation code

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.