add textwriter

main
reng 3 months ago
parent 568413b4b4
commit 58fd68de91
  1. 96
      Assets/Fonts/NotoSansTC-Regular SDF.asset
  2. 14
      Assets/Scenes/SampleScene.unity
  3. 65
      Assets/Scripts/OscHandler.cs
  4. 2
      Assets/Shaders/Material-light.mat
  5. 2
      Material/token.json/Google.Apis.Auth.OAuth2.Responses.TokenResponse-user

File diff suppressed because one or more lines are too long

@ -5308,10 +5308,10 @@ RectTransform:
- {fileID: 555167254}
m_Father: {fileID: 1317646465}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 70, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 617.5, y: -70}
m_SizeDelta: {x: 0, y: 70}
m_Pivot: {x: 1, y: 0}
--- !u!114 &1255800684
MonoBehaviour:
@ -6363,7 +6363,7 @@ MonoBehaviour:
m_fontSizeMax: 0
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 8
m_wordSpacing: 0
@ -7307,7 +7307,7 @@ MonoBehaviour:
m_fontSizeMax: 0
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 8
m_wordSpacing: 0
@ -7335,7 +7335,7 @@ MonoBehaviour:
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: -179.10236, y: 0, z: 203.52113, w: 0}
m_margin: {x: -179.10236, y: -68.00917, z: 203.52113, w: -79.34415}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0

@ -56,6 +56,8 @@ public class OscHandler : MonoBehaviour
[SerializeField]
public CanvasGroup hintforStep;
private IEnumerator coroutine_breath;
// Start is called before the first frame update
void Start()
@ -220,7 +222,8 @@ public class OscHandler : MonoBehaviour
}
statusText.text = input;
// statusText.text = input;
StartCoroutine(TypeWriter(statusText, input));
// hintforChat.alpha = 1f;
if (hintforChat.alpha < 1f)
{
@ -229,9 +232,14 @@ public class OscHandler : MonoBehaviour
if (hint.alpha < 1f)
{
// if (coroutine_hint != null) StopCoroutine(coroutine_hint);
// coroutine_hint = FadeCanvasGroup(hint, hint.alpha, 1f, _hintDuration);
// StartCoroutine(coroutine_hint);
if (coroutine_hint != null) StopCoroutine(coroutine_hint);
coroutine_hint = FadeCanvasGroup(hint, hint.alpha, 1f, _hintDuration);
coroutine_hint = BreathFade(hint);
StartCoroutine(coroutine_hint);
}
}
@ -241,12 +249,57 @@ public class OscHandler : MonoBehaviour
{
Debug.Log("/hint message received: " + text);
stepText.text = text;
// stepText.text = text;
StartCoroutine(TypeWriter(stepText, text));
StartCoroutine(FadeCanvasGroup(hintforStep, hintforStep.alpha, 1f, _hintDuration));
if (coroutine_hint != null) StopCoroutine(coroutine_hint);
coroutine_hint = FadeCanvasGroup(hint, hint.alpha, text.Length > 0 ? 1f : 0f, _hintDuration);
StartCoroutine(coroutine_hint);
if (coroutine_breath != null) StopCoroutine(coroutine_breath);
// coroutine_hint = FadeCanvasGroup(hint, hint.alpha, text.Length > 0 ? 1f : 0f, _hintDuration);
// StartCoroutine(coroutine_hint);
coroutine_breath = BreathFade(hintforStep);
StartCoroutine(coroutine_breath);
}
private IEnumerator BreathFade(CanvasGroup canvasGroup, float maxAlpha=1f, float minAlpha=0.33f,
float fadeInDuration=1.2f, float fadeOutDuration=1.2f, int cycles=20)
{
for (int i = 0; i < cycles; i++)
{
// Fade out
float elapsed = 0f;
while (elapsed < fadeOutDuration)
{
elapsed += Time.deltaTime;
canvasGroup.alpha = Mathf.Lerp(maxAlpha, minAlpha, elapsed / fadeOutDuration);
yield return null;
}
canvasGroup.alpha = minAlpha;
// Fade in
elapsed = 0f;
while (elapsed < fadeInDuration)
{
elapsed += Time.deltaTime;
canvasGroup.alpha = Mathf.Lerp(minAlpha, maxAlpha, elapsed / fadeInDuration);
yield return null;
}
canvasGroup.alpha = maxAlpha;
}
}
public IEnumerator TypeWriter(TextMeshProUGUI textComponent, string message, float typeSpeed = 0.2f)
{
textComponent.text = "";
foreach (char c in message)
{
textComponent.text += c;
yield return new WaitForSeconds(typeSpeed);
}
}
}

@ -78,7 +78,7 @@ Material:
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Strength: 0
- _Strength: 0.00052288384
- _UVSec: 0
- _ZWrite: 1
m_Colors:

@ -1 +1 @@
{"access_token":"ya29.a0AS3H6NxVIL2h8eKBgPqrDArFW0EH7QHYdU2AqolTgYiCMZXh4wkCdFt8bNWijX4y2DWgetcIyRGw-P-2N3mMgS5Zdbwvk3f3heekt3rjYvyOUM9vmTY7Prw1uGdtT2H_X7qjsv5RSesMWEaB0prENq-PEi962Ao4KQjBsyAoFAGbniy1-cSq2sOvJ6TW72I0jt1BQPQZaCgYKAW8SARESFQHGX2MiquVKBRv8Nvw-g6RlyOsbfw0207","token_type":"Bearer","expires_in":3599,"refresh_token":"1//0e-urCtqMVSK6CgYIARAAGA4SNwF-L9IrTWfNUsKFuBn8-mJmQxbXhkBlRW8776bD9xuFk1rFTaMH0dA9yRyESXHTchyXJDAJgkU","scope":"https://www.googleapis.com/auth/drive","Issued":"2025-09-12T16:31:55.048+08:00","IssuedUtc":"2025-09-12T08:31:55.048Z"}
{"access_token":"ya29.a0AS3H6NxTo2AL8j0SLr4KTpeYurgScqMCuE-f76GyCxdD0-1XcS0b8UMGj8BBdsZM8OtjghVI2xwidFE0CzXNJB7aIl5upWbCCKNGsTz-yYtmLTYGWP9fZKgyJc_r7ZO_Pi1UjSA4akOofa8Ps2cvtRqFgIT5yOzik5o7fjJF977YBIc5J4jy6MfgPoRFnLculQ3j199baCgYKAR0SARESFQHGX2MiirKW6ocuL43XzDKEwrXDcA0207","token_type":"Bearer","expires_in":3599,"refresh_token":"1//0e-urCtqMVSK6CgYIARAAGA4SNwF-L9IrTWfNUsKFuBn8-mJmQxbXhkBlRW8776bD9xuFk1rFTaMH0dA9yRyESXHTchyXJDAJgkU","scope":"https://www.googleapis.com/auth/drive","Issued":"2025-09-13T11:10:22.416+08:00","IssuedUtc":"2025-09-13T03:10:22.416Z"}
Loading…
Cancel
Save