unity3d 扩展NGUI Tweener —— TweenTime
2015-12-21 16:37
363 查看
这是今天做的一个小功能
策划想要一个时间滚动效果
那就搞呗!思路和之前写的tweenFillAmount一样
传送门:/article/4577974.html
时间格式:00:00:00
以下是代码,可以结合上文的链接一起看
本文链接:/article/4577978.html
策划想要一个时间滚动效果
那就搞呗!思路和之前写的tweenFillAmount一样
传送门:/article/4577974.html
时间格式:00:00:00
以下是代码,可以结合上文的链接一起看
#region HeadComments /* ======================================================================== * Copyright (C) 2015 Arthun * * 作 者:Arthun * 文件名称:TweenTime * 功 能:滚动时间 * 创建时间:2015/12/21 15:51:58 * * ========================================================================= */ #endregion using UnityEngine; [RequireComponent(typeof(UILabel))] [AddComponentMenu("NGUI/Tween/Tween Time")] public class TweenTime : UITweener { public float from = 1f; public float to = 1f; private bool mCached = false; private UILabel mLable; private void Cache() { mCached = true; mLable = GetComponent<UILabel>(); } public float value { get { if (!mCached) Cache(); return 0f; } set { if (!mCached) Cache(); if (mLable != null) mLable.text = getTimeFormat(value); } } protected override void OnUpdate(float factor, bool isFinished) { value = Mathf.Lerp(from, to, factor); } public override void SetStartToCurrentValue() { from = value; } public override void SetEndToCurrentValue() { to = value; } private string getTimeFormat(float time) { if (time <= 0) return "00:00:00"; System.TimeSpan ts = new System.TimeSpan(0, 0, (int)(time)); return ts.Hours.ToString().PadLeft(2, '0') + ":" + ts.Minutes.ToString().PadLeft(2, '0') + ":" + ts.Seconds.ToString().PadLeft(2, '0'); } }
本文链接:/article/4577978.html
相关文章推荐
- Unity 几种碰撞模式
- unity 2d遮挡透明显示整理
- 其他软件烘培的光影贴图在unity中如何使用
- unity5 资源管理和打包
- unity 自带样式名称(string to GUIStyle)
- Unity中实现全局管理类的几种方式
- Sublime Text 2配置U3D完美运行环境
- Unity5版本雾效果问题
- Unity开发-你必须知道的优化建议
- UNITY3d在移动设备上的一些优化实战(一)-概述
- 你在使用assetbundle时可能遇到的坑
- Unity3D Lightmap贴图加载替换
- 手游开发中所有特殊的文件夹
- SVN来管理Unity3d工程
- Unity ScriptObject
- OnEnable, Awake, Start order
- Unity3D工程版本管理方案
- Unity3D性能优化专题
- SkinnedMeshCombiner
- 更换Unity3D加载图标和屏蔽右键方法(4.0版本)