https://github.com/cemuka/signalsystem
Simple and easy to use signal system
https://github.com/cemuka/signalsystem
events signals unity unity3d
Last synced: 5 months ago
JSON representation
Simple and easy to use signal system
- Host: GitHub
- URL: https://github.com/cemuka/signalsystem
- Owner: cemuka
- Created: 2021-04-15T20:55:16.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-21T16:52:03.000Z (over 4 years ago)
- Last Synced: 2025-04-03T02:29:09.479Z (about 1 year ago)
- Topics: events, signals, unity, unity3d
- Language: C#
- Homepage:
- Size: 4.88 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```c#
// Sample usage
public static class Signaling
{
...
public static readonly Signal OnGameInit = new Signal();
public static readonly Signal OnPlayerScore = new Signal(); //newScore
...
}
public class GameManager : MonoBehaviour
{
private void Awake()
{
Signaling.OnGameInit.Invoke();
...
Signaling.OnPlayerScore.Invoke(10);
...
}
}
public class SomeView : MonoBehaviour
{
private void Start()
{
Signaling.OnGameInit.AddListener(Initialize);
Signaling.OnPlayerScore.AddListener(OnScore);
}
private void OnDestroy()
{
Signaling.OnGameInit.RemoveListener(Initialize);
Signaling.OnPlayerScore.RemoveListener(OnScore);
}
private void Initialize()
{
// display
}
private void OnScore(int newScore)
{
// update ui
}
}
```