Browse Source

User can click to skip current line of text.

master
chrisgregan 10 years ago
parent
commit
e098549584
  1. 34
      Assets/Fungus/UI/Scripts/Writer.cs
  2. 2
      Assets/FungusExamples/Sherlock/TheExperiment.unity
  3. 2
      Assets/Tests/UI/FakeWriterInput.cs

34
Assets/Fungus/UI/Scripts/Writer.cs

@ -397,17 +397,15 @@ namespace Fungus
} }
} }
break; break;
} }
inputFlag = false;
if (exit) if (exit)
{ {
break; break;
} }
} }
inputFlag = false;
isWriting = false; isWriting = false;
if (onComplete != null) if (onComplete != null)
@ -432,6 +430,12 @@ namespace Fungus
PartitionString(writeWholeWords, param, i, out left, out right); PartitionString(writeWholeWords, param, i, out left, out right);
text = ConcatenateString(startText, openText, closeText, left, right); text = ConcatenateString(startText, openText, closeText, left, right);
// No delay if user has clicked
if (inputFlag)
{
continue;
}
// Punctuation pause // Punctuation pause
if (left.Length > 0 && if (left.Length > 0 &&
IsPunctuation(left.Substring(left.Length - 1)[0])) IsPunctuation(left.Substring(left.Length - 1)[0]))
@ -496,11 +500,6 @@ namespace Fungus
return tempText; return tempText;
} }
public virtual void SetInputFlag()
{
inputFlag = true;
}
public virtual string GetTagHelp() public virtual string GetTagHelp()
{ {
return ""; return "";
@ -513,21 +512,28 @@ namespace Fungus
{ {
duration = 1f; duration = 1f;
} }
yield return new WaitForSeconds(duration); float timeRemaining = duration;
while (timeRemaining > 0f && !inputFlag)
{
timeRemaining -= Time.deltaTime;
yield return null;
}
} }
protected virtual IEnumerator DoWaitForInput(bool clear) protected virtual IEnumerator DoWaitForInput(bool clear)
{ {
inputFlag = false;
isWaitingForInput = true; isWaitingForInput = true;
while (!inputFlag) while (!inputFlag)
{ {
yield return null; yield return null;
} }
isWaitingForInput = false;
isWaitingForInput = false;
inputFlag = false; inputFlag = false;
if (clear) if (clear)
{ {
textUI.text = ""; textUI.text = "";
@ -576,7 +582,7 @@ namespace Fungus
// //
public virtual void OnNextLineEvent() public virtual void OnNextLineEvent()
{ {
SetInputFlag(); inputFlag = true;
} }
} }

2
Assets/FungusExamples/Sherlock/TheExperiment.unity

@ -2594,7 +2594,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
targetTextObject: {fileID: 1116800860} targetTextObject: {fileID: 1116800860}
writingSpeed: 60 writingSpeed: 10
punctuationPause: .25 punctuationPause: .25
hiddenTextColor: {r: 1, g: 1, b: 1, a: 0} hiddenTextColor: {r: 1, g: 1, b: 1, a: 0}
writeWholeWords: 0 writeWholeWords: 0

2
Assets/Tests/UI/FakeWriterInput.cs

@ -16,7 +16,7 @@ namespace Fungus
void DoFakeInput() void DoFakeInput()
{ {
Writer writer = GetComponent<Writer>(); Writer writer = GetComponent<Writer>();
writer.SetInputFlag(); writer.OnNextLineEvent();
} }
} }

Loading…
Cancel
Save