► Timers & Clocks ◄

A small, yet powerful collection of drag-and-drop timer and clock prefabs. Use these prefabs to make displaying time, or configuring logic that can trigger a time’s up event quick and easy.

Asset Store
Discussion Forum

Timer Prefab:
• 3 modes: Count-down, Count-up, and Count-up infinite
• Loop
• Adjustable speed
• Display current system or UTC time
• Inspector UnityEvent for time’s up
• Inspector List of UnityEvents triggered at assigned times
• Time string toggles for milliseconds, seconds, minutes, hours, and days
• Output time string to Unity Text or TextMeshProUGUI components
Double value type supports up to 922337193600 seconds (10,675,199 days)
• Add multiple timers to your scene for different purposes
• Optional 'SaveSessionTimer' script. Add this script to a timer object and assign a unique PlayerPrefs string name. If the timer was counting down/up and the app is closed or the scene is changed, when the scene is reopened by the app again, it will continue from its last value (where it left off, instead of starting over).



3D/UI Analog Clock Prefabs:
• 3D/UI clock with second, minute, and hour hand objects
• Use your own meshes/sprites
• Display the system time or a timer components time
• System time hour offset - allows simulation of timezones for different clocks

3D/UI Analog Stopwatch Prefabs:
• 3D/UI clock with second and minute hand objects attached to separate faces
• Use your own meshes/sprites
• Display a timer components time



https://www.youtube.com/watch?v=Bm1H6xtKB6A

How to make it run infinity?

[quote=“alahti”, post:2, topic: 592718]
How to make it run infinity?
[/quote]
I’ll add that in as an option.

-Timer Type can now be set to count up infinite to only display a time rather than promoting the user with a times up interface.

-Additional variables were made public to allow referencing these values for other purposes in your project from other scripts or for various reasons. If you want to create your own custom way of displaying the time variables when counting up you can now reference the following variables from this component:
*millisecond
*second
*minute
*hour
*day

-It's now possible to adjust the timeScale to make time move faster as well as the timer speed to make only the timer move faster through the inspector.

Version 1.03 is now available.

New feature requests have been added for version 1.04. Submitted today. Also added a 4.6.7 package for Unity 4 users.

  1. Timer moved to GameObject/UI/Timer Menu, you can now right click to add UI/Timer . Additionally, the canvas and event system objects are only added to the scene if they're not currently there, similar to standard UI components.

  2. Only display the fields you want in the timer text string available options are minutes, seconds, milliseconds for timer count up/down. When the timer counts up infinitely you can choose to display days, hours, minutes, seconds, milliseconds.

  3. Custom callback function using "UnityEvent" added to inspector to design your own times up configuration, easily call custom functions from other objects.

  4. Timescale can now optionally be set to 0 on times up.

  5. Methods have been added to control the timer from your other scripts, you can now make a reference to the timer and call the following:

GetTimerValue() returns the unformatted float value used for timer.
RestartTimer() resets the timer.
StopTimer() pause or stop the timer.
StartTimer() starts the timer.

To make this asset work with Text Mesh Pro all you need to do is replace the word "Text" with "TMPro.TextMeshProUGUI" or "TMPro.TextMeshPro" (depends which type of TMP text you will use) for the "timerText" variable on line 29 of update, do this in the STK_Timer script.

I've tried very hard but could not find a way to make a generic object field to automate this. I was able to generate the proper references through reflection and file checking but the object remained a generic object type rather than inherit the TMPro.TextMeshProUGUI type I was trying to manually assign through code. Because TMP uses its own namespace, I'm unable to access the text field in an automated or generic way. If I'm able to find a new trick to get around the namespcae issue for public variables I will automate this.

Version 1.04 now available.

1.05 will be submitted today. Added 3D analog clock prefab.

A uGUI analogue clock will also be included

Version 1.05 is now available.

Timer 1.051 submitted.
-Added ability to optionally display system time instead of a generic game time when the timer is set to count up infinitely. This can be used for the timer string, uGUI analog clock or 3D analog clock to display real world time.
-Added PlayMaker support with Actions for Start, Stop, Restart, and Reset.

1.051 will also include PlayMaker action support for Start, Stop, Restart and Reset functions. You can download the PlayMaker add-on package from the link in this forums description, at the top of this page.

Getting this when import to unity 5.1.3f3 playmaker actions
Assets/PlayMaker/Actions/Timer/TimerReset.cs(17,31): error CS1061: Type STK_Timer' does not contain a definition forResetTimer' and no extension method ResetTimer' of typeSTK_Timer' could be found (are you missing a using directive or an assembly reference?)

[quote=“geniraal”, post:14, topic: 592718]
Getting this when import to unity 5.1.3f3 playmaker actions
Assets/PlayMaker/Actions/Timer/TimerReset.cs(17,31): error CS1061: Type STK_Timer' does not contain a definition for ResetTimer’ and no extension method ResetTimer' of type STK_Timer’ could be found (are you missing a using directive or an assembly reference?)
[/quote]
Email me your invoice number and I’ll send you the 1.051 update, or you can wait for it to be approved. I changed the public methods a bit for the actions.You can also delete the script with errors and others should work fine.

I did mail you thanks

[quote=“geniraal”, post:16, topic: 592718]
I did mail you thanks
[/quote]
You’re welcome, let me know if you need more or need any adjustments.

version 1.051 is now available.

Looks like a great asset!

Does the asset also work for iOS and Android? And is it possible to count up and to add actions at certain times (also if the time is not up yet?). And can the time continue to count whilst the time is up?

[quote=“warpvr”, post:19, topic: 592718]
Looks like a great asset!

Does the asset also work for iOS and Android? And is it possible to count up and to add actions at certain times (also if the time is not up yet?). And can the time continue to count whilst the time is up?
[/quote]
Thanks, I currently don’t have any Apple hardware to test on, but I’ve used this asset many times on Android.

If you’re scripting, you can reference the timer like any other component in your scripts once the timer is in your scene to control it. With the public methods Start,Stop,Restart, Reset and create your own custom actions that you can pass into the component when needed. The UI will always display the timers current value.

Currently the timer by default will only call an event when time’s up. I do plan on adding multiple time based events some time in the near future.

I will make a bool to let the timer continue counting up when the time’s up for the next update, it currently will not count when the time limit is reached unless it’s reset.