InvokeRepeating
How do I use Invoke Repeating
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
30 | this.InvokeRepeating("LogStats", 10, 10); | 1 |
68 | InvokeRepeating ("TimeChange", 1, 1); | 2 |
File name: SupportLogger.cs
Copy
26 public void Start()
27 {
28 if (LogTrafficStats)
29 {
30 this.InvokeRepeating("LogStats", 10, 10);
31 }
32 }
File name: TimerScript.cs
Copy
53 public void InitTimer() {
54 //set time remaining if it doesn't exist yet
55 if (!PlayerPrefs.HasKey ("timer_time_remaining")){
56 this.timeRemaining = PlayerPrefs.GetInt("options_timer_duration");
57 PlayerPrefs.SetInt ("timer_time_remaining", this.timeRemaining);
58 }
59 else {
60 this.timeRemaining = PlayerPrefs.GetInt ("timer_time_remaining");
61 }
62 PlayerPrefs.Save ();
63
64
65 CancelInvoke ("TimeChange");
66 if (PlayerPrefs.GetInt ("options_timer_duration") > 0) {
67 this.timerEnabled = true;
68 InvokeRepeating ("TimeChange", 1, 1);
69 }
70 else {
71 this.timerEnabled = false;
72 }
73 }
InvokeRepeating 134 lượt xem
Gõ tìm kiếm nhanh...