-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLogic_TextTyping.cs
56 lines (48 loc) · 1.63 KB
/
Logic_TextTyping.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#region Header
/* ============================================
* Author : Strix
* Initial Creation Date : 2020-02-04
* Summary :
* Template : For Unity Editor V1
============================================ */
#endregion Header
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
namespace UIFramework
{
[System.Serializable]
public class Logic_TextTyping
{
public float fDurationSecond = 1f;
public float fDelaySecond;
public bool bUseRealTime = false;
public Logic_TextTyping(float fDurationSecond, float fDelaySecond = 0f)
{
this.fDurationSecond = fDurationSecond;
this.fDelaySecond = fDelaySecond;
}
public IEnumerator ExecuteLogic_Coroutine(ITextWrapperComponent pText, string strText)
{
if(bUseRealTime)
yield return new WaitForSecondsRealtime(fDelaySecond);
else
yield return new WaitForSeconds(fDelaySecond);
pText.strText = "";
float fProgress_0_1 = 0f;
while (fProgress_0_1 < 1f)
{
int iTextLength = (int)(strText.Length * fProgress_0_1);
pText.strText = strText.Substring(0, iTextLength);
if (bUseRealTime)
fProgress_0_1 += Time.unscaledDeltaTime / fDurationSecond;
else
fProgress_0_1 += Time.deltaTime / fDurationSecond;
yield return null;
}
pText.strText = strText;
yield break;
}
}
}