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)
using UnityEngine;
using System.Collections;
namespace Fungus
{
@ -13,9 +14,19 @@ namespace Fungus
"The block will execute when the game starts playing.")]
[AddComponentMenu("")]
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();
}
}

Loading…
Cancel
Save