Unity3d human blood strips making trivia

Source: Internet
Author: User

These days with Unity3d do a shooting games, want to make a human blood bar, think not its solution, then asked the online cattle and cows, solved, actually quite simple, GUI inside has a function drawtexturewithtexcoords can realize the cutting of the picture, Very convenient, after cutting, I believe everyone will operate, words do not say, paste the code and effect.

Using unityengine;

Using System.Collections;

using unityeditor;

Public class Drawtexture:monobehaviour {

public Texture back;//background map

public Texture fore;//foreground map

private float scale_height = 0.99f;

private float position_left=500f;

private float position_top=300f;

/ /Use this for initialization

void Start () {

   

   }

void Ongui ()

   {

GUI . Drawtexture (New Rect (Position_left, Position_top, Back.width, Back.height), back);

//gui . Drawtexture (New Rect (+, Fore.width, fore.height), fore);

if ( input.getkeyup ( Keycode.space)) {

9> scale_height=scale_height-0.01f;

           if (scale_height<0)

          < c22> scale_height=0;

               }

GUI . Label (New Rect (0,0,100,100), "Scale_height" +scale_height);

&NBSP;               GUI. Drawtexturewithtexcoords   (new  Rect (Position_left, position_top+back.height* (1-scale_height) , Fore.width, fore.height*scale_height), Fore,

                                < c32> new Rect (0,0,1, Scale_height), true);

   }

/ /Update is called once per frame

void Update () {

       

   }

}





The effect is good, haha.

Unity3d human blood strips making trivia

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.