Initial import of Rhyculator
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
728bb0c657
315 files changed
+96030
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
|
||||
public class HoldProgress : MonoBehaviour
|
||||
{
|
||||
public Image radialImage;
|
||||
private Coroutine progressCoroutine;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (radialImage != null)
|
||||
{
|
||||
radialImage.fillAmount = 0f;
|
||||
radialImage.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
// 開始
|
||||
public void StartProgress(float seconds)
|
||||
{
|
||||
if (radialImage == null || seconds <= 0f) return;
|
||||
|
||||
if (progressCoroutine != null)
|
||||
StopCoroutine(progressCoroutine);
|
||||
|
||||
radialImage.gameObject.SetActive(true);
|
||||
progressCoroutine = StartCoroutine(ProgressCoroutine(seconds));
|
||||
}
|
||||
|
||||
// 中斷
|
||||
public void StopProgress()
|
||||
{
|
||||
if (progressCoroutine != null)
|
||||
{
|
||||
StopCoroutine(progressCoroutine);
|
||||
progressCoroutine = null;
|
||||
}
|
||||
if (radialImage != null)
|
||||
{
|
||||
radialImage.fillAmount = 0f;
|
||||
radialImage.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ProgressCoroutine(float seconds)
|
||||
{
|
||||
float elapsed = 0f;
|
||||
while (elapsed < seconds)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
radialImage.fillAmount = 1f - Mathf.Clamp01(elapsed / seconds);
|
||||
yield return null;
|
||||
}
|
||||
radialImage.fillAmount = 0f;
|
||||
radialImage.gameObject.SetActive(false);
|
||||
progressCoroutine = null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user