Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeffreylanters/unity-timers
We may decide to execute a function not right now, but at a certain time later. That’s called “scheduling a call”. The Timers class helps you to do so with a clean and short syntax without having to worry about enumerators.
https://github.com/jeffreylanters/unity-timers
async timers unity
Last synced: 2 months ago
JSON representation
We may decide to execute a function not right now, but at a certain time later. That’s called “scheduling a call”. The Timers class helps you to do so with a clean and short syntax without having to worry about enumerators.
- Host: GitHub
- URL: https://github.com/jeffreylanters/unity-timers
- Owner: jeffreylanters
- License: mit
- Archived: true
- Created: 2019-01-16T11:37:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-07T08:39:57.000Z (about 3 years ago)
- Last Synced: 2024-08-02T05:17:08.930Z (6 months ago)
- Topics: async, timers, unity
- Language: C#
- Homepage:
- Size: 405 KB
- Stars: 22
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![readme splash](https://raw.githubusercontent.com/jeffreylanters/unity-timers/master/.github/WIKI/repository-readme-splash.png)
[![license](https://img.shields.io/badge/mit-license-red.svg?style=for-the-badge)](https://github.com/jeffreylanters/unity-timers/blob/master/LICENSE.md)
[![openupm](https://img.shields.io/npm/v/nl.elraccoone.timers?label=UPM®istry_uri=https://package.openupm.com&style=for-the-badge&color=232c37)](https://openupm.com/packages/nl.elraccoone.timers/)
[![build](https://img.shields.io/badge/build-passing-brightgreen.svg?style=for-the-badge)](https://github.com/jeffreylanters/unity-timers/actions)
[![deployment](https://img.shields.io/badge/state-success-brightgreen.svg?style=for-the-badge)](https://github.com/jeffreylanters/unity-timers/deployments)
[![stars](https://img.shields.io/github/stars/jeffreylanters/unity-timers.svg?style=for-the-badge&color=fe8523&label=stargazers)](https://github.com/jeffreylanters/unity-timers/stargazers)
[![awesome](https://img.shields.io/badge/listed-awesome-fc60a8.svg?style=for-the-badge)](https://github.com/jeffreylanters/awesome-unity-packages)
[![size](https://img.shields.io/github/languages/code-size/jeffreylanters/unity-timers?style=for-the-badge)](https://github.com/jeffreylanters/unity-timers/blob/master/Runtime)
[![sponsors](https://img.shields.io/github/sponsors/jeffreylanters?color=E12C9A&style=for-the-badge)](https://github.com/sponsors/jeffreylanters)
[![donate](https://img.shields.io/badge/donate-paypal-F23150?style=for-the-badge)](https://paypal.me/jeffreylanters)We may decide to execute a function not right now, but at a certain time later. That’s called “scheduling a call”. The Timers class helps you to do so with a clean and short syntax without having to worry about enumerators.
[**Installation**](#installation) ·
[**Documentation**](#documentation) ·
[**License**](./LICENSE.md)**Made with ♥ by Jeffrey Lanters**
# Installation
### Using the Unity Package Manager
Install the latest stable release using the Unity Package Manager by adding the following line to your `manifest.json` file located within your project's Packages directory, or by adding the Git URL to the Package Manager Window inside of Unity.
```json
"nl.elraccoone.timers": "git+https://github.com/jeffreylanters/unity-timers"
```### Using OpenUPM
The module is availble on the OpenUPM package registry, you can install the latest stable release using the OpenUPM Package manager's Command Line Tool using the following command.
```sh
openupm add nl.elraccoone.timers
```# Documentation
## Syntax
```cs
using ElRaccoone.Timers;
Timers.SetTimeout(/* miliseconds */ 1000, /* callback */ () => { /* ... */ });
Timers.SetInterval(/* miliseconds */ 1000, /* callback */ () => { /* ... */ });
```## Description
We may decide to execute a function not right now, but at a certain time later. That’s called “scheduling a call”. Note that the timers are using unscaled time.
There are two methods for it:
- setTimeout allows to run a function once after the interval of time.
- setInterval allows to run a function regularly with the interval between the runs.## Examples
```cs
public class MyClass {
private void Awake () {
Timers.SetTimeout(1000, () => {
Debug.Log("A second has passed!");
});
Timers.SetTimeout(1000, Notifiy);
Timers.SetInterval(2500, Notifiy);
}
private void Notify () {
Debug.Log("Notify!!");
}
}
```