From 7ba3cdd21f08cf7ab5917a413d7d248f739069fb Mon Sep 17 00:00:00 2001 From: jparent Date: Sun, 31 Jan 2016 14:27:50 -0500 Subject: [PATCH] make the menu screen skippable after certain time --- Assets/scripts/MenuInteractions.cs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Assets/scripts/MenuInteractions.cs b/Assets/scripts/MenuInteractions.cs index 3bf539f..7f344b4 100644 --- a/Assets/scripts/MenuInteractions.cs +++ b/Assets/scripts/MenuInteractions.cs @@ -4,9 +4,10 @@ using System.Collections; public class MenuInteractions : MonoBehaviour { public int nextLevel; - public bool isSkippable = true; public bool hasAutoSkips = false; - public int timeBeforeSkip = 10; + public int timeBeforeAutoSkip = 10; + public int timeBeforeSkippable = 0; + private bool isSkippable = false; // Update is called once per frame void Update() @@ -18,16 +19,13 @@ public class MenuInteractions : MonoBehaviour Application.LoadLevel(nextLevel); } } + } void Start() { - // this won't lead anywhere... let's fix it - if(!isSkippable && !hasAutoSkips) - { - isSkippable = true; - hasAutoSkips = true; - } + + StartCoroutine(EnableSkip()); if (hasAutoSkips) { @@ -37,8 +35,15 @@ public class MenuInteractions : MonoBehaviour IEnumerator AutoSkip() { - yield return new WaitForSeconds(timeBeforeSkip); + yield return new WaitForSeconds(timeBeforeAutoSkip); Application.LoadLevel(nextLevel); } + + IEnumerator EnableSkip() + { + yield return new WaitForSeconds(timeBeforeSkippable); + isSkippable = true; + + } }