日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Unity3D 人形血条制作小知识

發布時間:2024/4/13 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Unity3D 人形血条制作小知识 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這幾天用Unity3D做個射擊小游戲,想做個人形的血條。百思不得其解,后來問了網上的牛牛們,攻克了,事實上挺簡單的,GUI里面有個函數DrawTextureWithTexCoords就能夠實現圖片的裁剪。非常方便。裁剪之后。相信大家就都會操作了。話不多說。貼上代碼與截圖效果。

using?UnityEngine;

using?System.Collections;

using???UnityEditor;

?

public?class?drawTexture : MonoBehaviour {

????public?Texture back;//背景圖

????public?Texture fore;//前景圖

????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 (500, 300, fore.width, fore.height), fore);

?

????????if?(Input.GetKeyUp(KeyCode.Space)) {

????????????scale_height=scale_height- 0.01f;

????????????if(scale_height<0)

????????????????scale_height=0;

????????????????}

????????GUI.Label (new?Rect(0,0,100,100),"scale_height"+scale_height);

????????GUI.DrawTextureWithTexCoords?(new?Rect (position_left, position_top+back.height*(1-scale_height), fore.width, fore.height*scale_height), fore,

???????????????????????????????????new?Rect(0,0,1, scale_height),true);

????}

????// Update is called once per frame

????void?Update () {

?????????

????}

}


效果圖:




效果還不錯吧。哈哈。

總結

以上是生活随笔為你收集整理的Unity3D 人形血条制作小知识的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。