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. 13
      Assets/Fungus/Scripts/EventHandlers/GameStarted.cs

13
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
{ {
@ -14,8 +15,18 @@ namespace Fungus
[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