Browse Source

Click to instant complete text writing

master
chrisgregan 10 years ago
parent
commit
b5aa348fb4
  1. 49
      Assets/Fungus/Dialog/Scripts/Dialog.cs
  2. BIN
      ProjectSettings/EditorBuildSettings.asset
  3. BIN
      ProjectSettings/ProjectSettings.asset

49
Assets/Fungus/Dialog/Scripts/Dialog.cs

@ -131,23 +131,10 @@ namespace Fungus
}
// Zero speed means write instantly
// Also write instantly if text contains rich text markup tags
if (currentSpeed == 0 ||
text.Contains("<"))
{
foreach (Glyph glyph in glyphs)
{
if (glyph.type == GlyphType.Character)
{
storyText.text += glyph.param;
}
}
if (onWritingComplete != null)
{
onWritingComplete();
}
yield break;
currentSpeed = 10000;
}
GameObject typingAudio = null;
@ -161,12 +148,6 @@ namespace Fungus
typingAudio.audio.Play();
}
float writeDelay = 0f;
if (currentSpeed > 0)
{
writeDelay = (1f / (float)currentSpeed);
}
float timeAccumulator = 0f;
int i = 0;
@ -174,16 +155,13 @@ namespace Fungus
{
timeAccumulator += Time.deltaTime;
bool skipWriting = false;
/*
if (Input.GetMouseButtonDown(0))
float writeDelay = 0f;
if (currentSpeed > 0)
{
skipWriting = true;
writeDelay = (1f / (float)currentSpeed);
}
*/
while (skipWriting ||
timeAccumulator > writeDelay)
while (timeAccumulator > writeDelay)
{
timeAccumulator -= writeDelay;
@ -220,6 +198,11 @@ namespace Fungus
}
storyText.text += start + glyph.param + end;
if (Input.GetMouseButtonDown(0))
{
currentSpeed = 10000; // Write instantly
}
}
// Add a wait glyph on punctuation marks
@ -247,10 +230,11 @@ namespace Fungus
glyphs[i + 1].type == GlyphType.Character &&
IsPunctuation(glyphs[i + 1].param));
if (!skipCharacter &&
!skipWriting)
if (!skipCharacter)
{
yield return new WaitForSeconds(currentPunctuationPause);
}
}
break;
@ -285,16 +269,14 @@ namespace Fungus
{
duration = 1f;
}
if (!skipWriting)
{
yield return new WaitForSeconds(duration);
timeAccumulator = 0f;
}
break;
case GlyphType.WaitForInputNoClear:
OnWaitForInputTag(true);
yield return StartCoroutine(WaitForInput(null));
timeAccumulator = 0f;
OnWaitForInputTag(false);
break;
@ -302,11 +284,13 @@ namespace Fungus
OnWaitForInputTag(true);
yield return StartCoroutine(WaitForInput(null));
OnWaitForInputTag(false);
timeAccumulator = 0f;
storyText.text = "";
break;
case GlyphType.Clear:
storyText.text = "";
timeAccumulator = 0f;
break;
case GlyphType.Speed:
@ -315,6 +299,7 @@ namespace Fungus
currentSpeed = 0f;
}
writeDelay = 0;
timeAccumulator = 0f;
if (currentSpeed > 0)
{
writeDelay = (1f / (float)currentSpeed);

BIN
ProjectSettings/EditorBuildSettings.asset

Binary file not shown.

BIN
ProjectSettings/ProjectSettings.asset

Binary file not shown.
Loading…
Cancel
Save