|
|
|
@ -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 |
|
|
|
|
{ |
|
|
|
@ -17,6 +18,32 @@ namespace Fungus
|
|
|
|
|
[Tooltip("Object that the user can click or tap on")] |
|
|
|
|
[SerializeField] protected Clickable2D clickableObject; |
|
|
|
|
|
|
|
|
|
[Tooltip("Wait for a number of frames before executing the block.")] |
|
|
|
|
[SerializeField] protected int waitFrames = 1; |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Executing a block on the same frame that the object is clicked can cause |
|
|
|
|
/// input problems (e.g. auto completing Say Dialog text). A single frame delay |
|
|
|
|
/// fixes the problem. |
|
|
|
|
/// </summary> |
|
|
|
|
protected virtual IEnumerator DoExecuteBlock(int numFrames) |
|
|
|
|
{ |
|
|
|
|
if (numFrames == 0) |
|
|
|
|
{ |
|
|
|
|
ExecuteBlock(); |
|
|
|
|
yield break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int count = Mathf.Max(waitFrames, 1); |
|
|
|
|
while (count > 0) |
|
|
|
|
{ |
|
|
|
|
count--; |
|
|
|
|
yield return new WaitForEndOfFrame(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ExecuteBlock(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region Public members |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -26,7 +53,7 @@ namespace Fungus
|
|
|
|
|
{ |
|
|
|
|
if (clickableObject == this.clickableObject) |
|
|
|
|
{ |
|
|
|
|
ExecuteBlock(); |
|
|
|
|
StartCoroutine(DoExecuteBlock(waitFrames)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|