查看: 1306|回复: 0
打印 上一主题 下一主题

另一个gui实现时钟的效果(电子表)

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-2-16 14:28:25 |只看该作者 |倒序浏览
var Tu1 : Texture2D;

var Time1 : float = 0;

function FixedUpdate () {

Time1 += Time.deltaTime;

}

function OnGUI () {

GUI.Label(Rect(250,170,161,62),getTime(Time1));
GUIUtility.RotateAroundPivot (6*Time1, Vector2(103, 200));

GUI.DrawTexture(Rect(100,100,6,100),Tu1);//秒针

GUIUtility.RotateAroundPivot (-6*Time1, Vector2(103, 200));
GUIUtility.RotateAroundPivot (0.1*Time1, Vector2(103, 200));

GUI.DrawTexture(Rect(100,120,6,80),Tu1);//分针

GUIUtility.RotateAroundPivot (-0.1*Time1, Vector2(103, 200));
GUIUtility.RotateAroundPivot (0.1/60*Time1, Vector2(103, 200));

GUI.DrawTexture(Rect(100,140,6,60),Tu1);//时针

GUIUtility.RotateAroundPivot (-0.1/60*Time1, Vector2(103, 200));

}

function getTime(time : float) : String{

if(time<0){

return "00:00:00";

}

var lastTime : String = "";

var hour = Mathf.FloorToInt(time/3600%24);

if(hour/10 >=1){

lastTime+="" + hour;

}else{

lastTime +="0" + hour;

}

var minute = Mathf.FloorToInt(time/60%60);

if(minute/10 >=1){

lastTime+=":" + minute;

}else{

lastTime +=":0" + minute;

}

var second = Mathf.FloorToInt(time%60);

if(second/10 >=1){

lastTime+=":" + second;

}else{

lastTime +=":0" + second;

}&aring;

return lastTime;

}



转自unity3d8.com
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-11-10 18:01 , Processed in 0.090972 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部