Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GameManager: MonoBehaviour
- {
- public delegate void OnCompleted();
- public static event OnCompleted OnEndTurn;
- private void Update()
- {
- if (Input.GetButtonUp("Fire1"))
- {
- //Here I use the fire button to end the turn
- if (OnEndTurn != null)
- {
- //All the code you want to run before the turn ends goes here
- //.....
- OnEndTurn();
- }
- }
- }
- }
- //Now the listner
- public class Listner: MonoBehaviour
- {
- void Start()
- {
- //Subscribe to the event
- HelpOthers.OnEndTurn += WhatToDoWhenTurnEnds;
- }
- void WhatToDoWhenTurnEnds()
- {
- print("I do this when turn ends");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement