added yarn spinner package

This commit is contained in:
2026-08-14 13:27:17 +02:00
parent c140236bf7
commit c483bda3ea
573 changed files with 81459 additions and 0 deletions
@@ -0,0 +1,50 @@
/*
Yarn Spinner is licensed to you under the terms found in the file LICENSE.md.
*/
using System;
using System.Collections;
using UnityEngine;
using System.Collections.Generic;
#if USE_TMP
using TMPro;
#else
using TextMeshProUGUI = Yarn.Unity.TMPShim;
#endif
using System.Threading;
#nullable enable
namespace Yarn.Unity
{
public static class Effects
{
public static IEnumerator FadeAlpha(CanvasGroup canvas, float from, float to, float duration, CancellationToken token)
{
return YarnTask.ToCoroutine(() => FadeAlphaAsync(canvas, from, to, duration, token));
}
public static async YarnTask FadeAlphaAsync(CanvasGroup canvas, float from, float to, float duration, CancellationToken token)
{
if (duration == 0)
{
canvas.alpha = to;
return;
}
canvas.alpha = from;
float accumulator = 0;
while (!token.IsCancellationRequested && accumulator < duration)
{
accumulator += Time.deltaTime;
canvas.alpha = Mathf.Lerp(from, to, accumulator / duration);
await YarnTask.Yield();
}
canvas.alpha = to;
}
}
}