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

Unity3D定时器程序实现

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

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

跳转到指定楼层
楼主
发表于 2012-4-7 10:31:29 |只看该作者 |倒序浏览
本程序演示了如何创建多个定时器,并对定时器样式进行定制以及接受定时器到时的通知信息。



1.创建定时器:



TimerManager m_timerManager1 = gameObject.AddComponent("TimerManager") as TimerManager;



2.自定义定时器



本程序演示了如何创建多个定时器,并对定时器样式进行定制以及接受定时器到时的通知信息。



1.创建定时器:



TimerManager m_timerManager1 = gameObject.AddComponent("TimerManager") as TimerManager;



2.自定义定时器



//void initTimer(int timerID, int countDownVal, Rect timerRect, GameObject timerHandler, GUIStyle timerStyle)



m_timerManager1.initTimer(1, 11, new Rect(100, 100, 100, 100), gameObject, mySkin.customStyles[0]);



3.控制定时器



m_timerManager1.startTimer();



m_timerManager1.pauseTimer();



m_timerManager1.resumeTimer();



m_timerManager1.stopTimer();



4.监听定时器通知信息



void TimeUpMessage(int timerID)



{      



    UnityEditor.EditorUtility.DisplayDialog("TimeUpMessage", "Timer ID: " + timerID.ToString(), "OK");



}





本文转自:http://www.supersuraccoon-cocos2 ... r-demo-for-unity3d/
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

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

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-5-3 13:24 , Processed in 0.094983 second(s), 29 queries .

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

© 2008-2019 Narkii Inc.

回顶部