Browse Source

Added WaitForFrames property to GameStart event handler. Default is wait for 1 frame (to reduce startup order issues).

master
Christopher 8 years ago
parent
commit
21b15329c6
  1. 15
      Assets/Fungus/Scripts/EventHandlers/GameStarted.cs

15
Assets/Fungus/Scripts/EventHandlers/GameStarted.cs

@ -2,6 +2,7 @@
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) // It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
@ -13,9 +14,19 @@ namespace Fungus
"The block will execute when the game starts playing.")] "The block will execute when the game starts playing.")]
[AddComponentMenu("")] [AddComponentMenu("")]
public class GameStarted : EventHandler public class GameStarted : EventHandler
{ {
protected virtual void Start() [Tooltip("Wait for a number of frames after startup before executing the Block. Can help fix startup order issues.")]
[SerializeField] protected int waitForFrames = 1;
protected virtual IEnumerator Start()
{ {
int frameCount = waitForFrames;
while (frameCount > 0)
{
yield return new WaitForEndOfFrame();
frameCount--;
}
ExecuteBlock(); ExecuteBlock();
} }
} }

Loading…
Cancel
Save