Rebuild the game as a single code-driven scene with a package-folder pack source
- One empty scene; App builds the canvas, safe-area layout and a shared 5x6 Grid in code. Pages (Intro, Main, Choose, Play, Account, Settings) replace 5 scenes, 5 prefabs and the per-cell spawner/display components. - Packs: the game reads Rhyculator/package/ (with All files access) or the app folder, like a plugged-in USB stick. Zips stay where they are and are extracted to a cache keyed by name/size/mtime; folders are read directly. Scans run every second on a background thread. Old songs/ imports and inbox zips are migrated automatically. - Download packs by 8-char code from the new pack website, or via rhyculator://pack/<code> links; opened/shared zips go into the package folder. - Play: pause/resume/retry, auto-pause on background, combo and progress bar; judging and scoring unchanged. Choose page fits 9:16 screens; empty state, pack delete. Android back key handled everywhere. - Slimming: removed TextMesh Pro, unused 2D/Timeline/VisualScripting/etc. packages and modules, scene template, unused sprites; menu theme wav (20MB) -> ogg (2.3MB). Build profile replaced by explicit settings in BuildAndroid. - Tests: PackLibrary/PackReader/migration/serializer tests (39 passing). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6d5f66ac6a
commit
ddd5fdc28b
295 files changed
+3854
-82126
No files matched your search
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
// 依 SongClock 把譜面事件放到格子上(遊玩與主畫面的背景譜面共用)
|
||||
public class ChartPlayer
|
||||
{
|
||||
private readonly List<ChartEvent> events;
|
||||
private int next;
|
||||
|
||||
public int Count => events.Count;
|
||||
|
||||
public ChartPlayer(List<ChartEvent> events)
|
||||
{
|
||||
this.events = events;
|
||||
}
|
||||
|
||||
// 從某個時間點開始(之前的事件略過,例如主畫面音樂已經在播)
|
||||
public void Seek(double time)
|
||||
{
|
||||
next = 0;
|
||||
while (next < events.Count && events[next].hitTime < time) next++;
|
||||
}
|
||||
|
||||
public void Tick(Grid grid, double now)
|
||||
{
|
||||
double until = now + Grid.AppearLead;
|
||||
while (next < events.Count && events[next].hitTime <= until)
|
||||
{
|
||||
var e = events[next++];
|
||||
switch (e.type)
|
||||
{
|
||||
case "tap": grid.ShowNote(e.x, e.y, NoteType.Tap, e.hitTime); break;
|
||||
case "hold": grid.ShowNote(e.x, e.y, NoteType.Hold, e.hitTime, e.holdMs); break;
|
||||
case "slide": grid.ShowNote(e.x, e.y, NoteType.Slide, e.hitTime); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad11e114219d549499dbd8005be48111
|
||||
@@ -0,0 +1,325 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public enum NoteType { Tap, Hold, Slide }
|
||||
public enum CellFlash { White, Blue, Green, Orange, Red }
|
||||
|
||||
// 5x6 的格子:所有畫面共用一個,畫面只設定格子上的圖示、文字與音符
|
||||
// 每格由下而上:外框(判定閃色)、圖示、音符、長按進度環、文字
|
||||
// 音符動畫完全由 SongClock 決定,保證在判定時間時縮放剛好為 1
|
||||
public class Grid : MonoBehaviour
|
||||
{
|
||||
public const int Columns = 5;
|
||||
public const int Rows = 6;
|
||||
// 1080 寬的畫布單位
|
||||
public const float CellSize = 180f;
|
||||
public const float Spacing = 20f;
|
||||
public const float Width = Columns * CellSize + (Columns - 1) * Spacing;
|
||||
public const float Height = Rows * CellSize + (Rows - 1) * Spacing;
|
||||
|
||||
// 音符在判定點前多久出現(秒);與 Maker 的 zones.APPEAR_MS 一致
|
||||
public const double AppearLead = 0.5;
|
||||
private const double FillDuration = 0.2; // 出現時的圓形填滿動畫
|
||||
private const double GrowHalf = 0.2; // 判定點前後的縮放區間:0.5 → 1 → 1.5
|
||||
private const float FlashDuration = 0.3f;
|
||||
private const float RingScale = 1.2f;
|
||||
|
||||
// 音符超過判定時間仍未被處理(x, y, 種類)
|
||||
public event Action<int, int, NoteType> NoteExpired;
|
||||
|
||||
private class Cell
|
||||
{
|
||||
public RectTransform rt;
|
||||
public Image frame, icon, note, ring;
|
||||
public Text label;
|
||||
|
||||
public bool hasNote;
|
||||
public NoteType type;
|
||||
public double hitTime;
|
||||
public int holdMs;
|
||||
|
||||
public float flashEnd;
|
||||
public bool flashColored; // 目前是判定色(優先於按住時的白色)
|
||||
public float ringStart, ringLength;
|
||||
}
|
||||
|
||||
private readonly Cell[,] cells = new Cell[Columns, Rows];
|
||||
private RectTransform area;
|
||||
private Sprite frameDefault, noteTap, noteHold, noteSlide;
|
||||
private Sprite[] flashSprites;
|
||||
private Font font;
|
||||
|
||||
public static Grid Create(RectTransform parent, Font font)
|
||||
{
|
||||
var go = new GameObject("Grid", typeof(RectTransform));
|
||||
go.transform.SetParent(parent, false);
|
||||
var g = go.AddComponent<Grid>();
|
||||
g.Build(font);
|
||||
return g;
|
||||
}
|
||||
|
||||
void Build(Font f)
|
||||
{
|
||||
font = f;
|
||||
frameDefault = Sprites.Get("Grid_dgray");
|
||||
noteTap = Sprites.Get("TapNote");
|
||||
noteHold = Sprites.Get("HoldNote");
|
||||
noteSlide = Sprites.Get("SlideNote");
|
||||
flashSprites = new[]
|
||||
{
|
||||
Sprites.Get("Grid_white"), Sprites.Get("Grid_blue"), Sprites.Get("Grid_green"),
|
||||
Sprites.Get("Grid_orange"), Sprites.Get("Grid_red"),
|
||||
};
|
||||
Sprite ringSprite = Sprites.Get("LongPressHint");
|
||||
|
||||
area = (RectTransform)transform;
|
||||
area.anchorMin = area.anchorMax = area.pivot = new Vector2(0.5f, 0f);
|
||||
area.sizeDelta = new Vector2(Width, Height);
|
||||
|
||||
for (int y = 0; y < Rows; y++)
|
||||
for (int x = 0; x < Columns; x++)
|
||||
{
|
||||
var c = new Cell();
|
||||
var go = new GameObject($"Cell {x},{y}", typeof(RectTransform));
|
||||
go.transform.SetParent(area, false);
|
||||
c.rt = (RectTransform)go.transform;
|
||||
c.rt.anchorMin = c.rt.anchorMax = Vector2.zero;
|
||||
c.rt.pivot = new Vector2(0.5f, 0.5f);
|
||||
c.rt.sizeDelta = new Vector2(CellSize, CellSize);
|
||||
c.rt.anchoredPosition = new Vector2(x * (CellSize + Spacing) + CellSize / 2, y * (CellSize + Spacing) + CellSize / 2);
|
||||
|
||||
c.frame = Layer(c.rt, "Frame", frameDefault);
|
||||
c.icon = Layer(c.rt, "Icon", null);
|
||||
c.icon.preserveAspect = true;
|
||||
c.note = Layer(c.rt, "Note", null);
|
||||
c.note.type = Image.Type.Filled;
|
||||
c.note.fillMethod = Image.FillMethod.Radial360;
|
||||
c.note.fillOrigin = 2;
|
||||
c.note.fillClockwise = true;
|
||||
c.ring = Layer(c.rt, "Ring", ringSprite);
|
||||
c.ring.type = Image.Type.Filled;
|
||||
c.ring.fillMethod = Image.FillMethod.Radial360;
|
||||
c.ring.fillOrigin = 2;
|
||||
c.ring.rectTransform.localScale = Vector3.one * RingScale;
|
||||
c.ring.enabled = false;
|
||||
|
||||
var lgo = new GameObject("Label", typeof(RectTransform));
|
||||
lgo.transform.SetParent(c.rt, false);
|
||||
c.label = lgo.AddComponent<Text>();
|
||||
c.label.font = font;
|
||||
c.label.fontStyle = FontStyle.Bold;
|
||||
c.label.alignment = TextAnchor.MiddleCenter;
|
||||
c.label.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
c.label.verticalOverflow = VerticalWrapMode.Overflow;
|
||||
c.label.raycastTarget = false;
|
||||
Stretch(c.label.rectTransform);
|
||||
c.label.enabled = false;
|
||||
|
||||
cells[x, y] = c;
|
||||
}
|
||||
}
|
||||
|
||||
static Image Layer(RectTransform parent, string name, Sprite sprite)
|
||||
{
|
||||
var go = new GameObject(name, typeof(RectTransform));
|
||||
go.transform.SetParent(parent, false);
|
||||
var img = go.AddComponent<Image>();
|
||||
img.sprite = sprite;
|
||||
img.raycastTarget = false; // 格子不擋觸控判斷(UIHitTest 只看面板、按鈕)
|
||||
img.enabled = sprite != null;
|
||||
Stretch(img.rectTransform);
|
||||
return img;
|
||||
}
|
||||
|
||||
static void Stretch(RectTransform rt)
|
||||
{
|
||||
rt.anchorMin = Vector2.zero;
|
||||
rt.anchorMax = Vector2.one;
|
||||
rt.offsetMin = rt.offsetMax = Vector2.zero;
|
||||
}
|
||||
|
||||
public static bool InBounds(int x, int y) => x >= 0 && y >= 0 && x < Columns && y < Rows;
|
||||
|
||||
// 由 App 每幀呼叫:在畫面處理完觸控(判定)之後、生成新音符之前
|
||||
public void Tick()
|
||||
{
|
||||
double now = SongClock.Now;
|
||||
float t = Time.unscaledTime;
|
||||
for (int y = 0; y < Rows; y++)
|
||||
for (int x = 0; x < Columns; x++)
|
||||
{
|
||||
var c = cells[x, y];
|
||||
if (c.hasNote)
|
||||
{
|
||||
double d = now - c.hitTime;
|
||||
if (d > NoteJudge.BadWindow)
|
||||
{
|
||||
var type = c.type;
|
||||
ClearNote(x, y);
|
||||
NoteExpired?.Invoke(x, y, type);
|
||||
}
|
||||
else UpdateNote(c, d);
|
||||
}
|
||||
if (c.flashEnd > 0 && t >= c.flashEnd)
|
||||
{
|
||||
c.frame.sprite = frameDefault;
|
||||
c.flashEnd = 0;
|
||||
}
|
||||
if (c.ring.enabled)
|
||||
{
|
||||
float p = c.ringLength > 0 ? (t - c.ringStart) / c.ringLength : 1f;
|
||||
if (p >= 1f) c.ring.enabled = false;
|
||||
else c.ring.fillAmount = 1f - p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 圖示與文字 ----------
|
||||
|
||||
public void SetIcon(int x, int y, Sprite sprite)
|
||||
{
|
||||
if (!InBounds(x, y)) return;
|
||||
var c = cells[x, y];
|
||||
c.icon.sprite = sprite;
|
||||
c.icon.enabled = sprite != null;
|
||||
}
|
||||
|
||||
public void SetLabel(int x, int y, string text, Color color, float fontScale = 0.55f)
|
||||
{
|
||||
if (!InBounds(x, y)) return;
|
||||
var l = cells[x, y].label;
|
||||
l.enabled = !string.IsNullOrEmpty(text);
|
||||
l.text = text ?? "";
|
||||
l.color = color;
|
||||
l.fontSize = Mathf.RoundToInt(CellSize * fontScale);
|
||||
}
|
||||
|
||||
// 清除所有圖示、文字、音符與進度環(換畫面時)
|
||||
public void ClearAll()
|
||||
{
|
||||
for (int y = 0; y < Rows; y++)
|
||||
for (int x = 0; x < Columns; x++)
|
||||
{
|
||||
var c = cells[x, y];
|
||||
ClearNote(x, y);
|
||||
SetIcon(x, y, null);
|
||||
c.label.enabled = false;
|
||||
c.ring.enabled = false;
|
||||
c.frame.sprite = frameDefault;
|
||||
c.flashEnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 音符 ----------
|
||||
|
||||
public void ShowNote(int x, int y, NoteType type, double hitTime, int holdMs = 0)
|
||||
{
|
||||
if (!InBounds(x, y)) return;
|
||||
var c = cells[x, y];
|
||||
// 同格還有未處理的音符:視為 Miss,避免音符無聲消失造成統計少算
|
||||
if (c.hasNote)
|
||||
{
|
||||
var old = c.type;
|
||||
ClearNote(x, y);
|
||||
NoteExpired?.Invoke(x, y, old);
|
||||
}
|
||||
c.hasNote = true;
|
||||
c.type = type;
|
||||
c.hitTime = hitTime;
|
||||
c.holdMs = holdMs;
|
||||
c.note.sprite = type == NoteType.Tap ? noteTap : type == NoteType.Hold ? noteHold : noteSlide;
|
||||
c.note.enabled = true;
|
||||
UpdateNote(c, SongClock.Now - hitTime);
|
||||
}
|
||||
|
||||
// d = 目前時間 - 判定時間
|
||||
static void UpdateNote(Cell c, double d)
|
||||
{
|
||||
float fill = (float)Math.Min(1.0, Math.Max(0.0, (d + AppearLead) / FillDuration));
|
||||
float scale = d < -GrowHalf ? 0.5f : (float)(1.0 + d / (2 * GrowHalf));
|
||||
float alpha = scale > 1f ? Mathf.Clamp01(1f - (scale - 1f) / 0.5f) : 1f;
|
||||
c.note.fillAmount = fill;
|
||||
c.note.color = new Color(1, 1, 1, alpha);
|
||||
c.note.rectTransform.localScale = Vector3.one * scale;
|
||||
}
|
||||
|
||||
public bool HasNote(int x, int y) => InBounds(x, y) && cells[x, y].hasNote;
|
||||
public NoteType NoteTypeAt(int x, int y) => cells[x, y].type;
|
||||
public double HitTime(int x, int y) => cells[x, y].hitTime;
|
||||
public int HoldMs(int x, int y) => cells[x, y].holdMs;
|
||||
|
||||
public void ClearNote(int x, int y)
|
||||
{
|
||||
if (!InBounds(x, y)) return;
|
||||
var c = cells[x, y];
|
||||
c.hasNote = false;
|
||||
c.note.enabled = false;
|
||||
c.note.rectTransform.localScale = Vector3.one;
|
||||
}
|
||||
|
||||
// ---------- 回饋 ----------
|
||||
|
||||
public void Flash(int x, int y, CellFlash color)
|
||||
{
|
||||
if (!InBounds(x, y)) return;
|
||||
var c = cells[x, y];
|
||||
bool colored = color != CellFlash.White;
|
||||
// 按住時的白色不覆蓋判定色
|
||||
if (!colored && c.flashEnd > 0 && c.flashColored) return;
|
||||
c.frame.sprite = flashSprites[(int)color];
|
||||
c.flashColored = colored;
|
||||
c.flashEnd = Time.unscaledTime + FlashDuration;
|
||||
}
|
||||
|
||||
public void StartRing(int x, int y, float seconds)
|
||||
{
|
||||
if (!InBounds(x, y) || seconds <= 0) return;
|
||||
var c = cells[x, y];
|
||||
c.ring.enabled = true;
|
||||
c.ring.fillAmount = 1f;
|
||||
c.ringStart = Time.unscaledTime;
|
||||
c.ringLength = seconds;
|
||||
}
|
||||
|
||||
public void StopRing(int x, int y)
|
||||
{
|
||||
if (InBounds(x, y)) cells[x, y].ring.enabled = false;
|
||||
}
|
||||
|
||||
// 螢幕座標 → 格子;在格子外(含間距)回傳 false
|
||||
public bool CellAt(Vector2 screenPos, out int x, out int y)
|
||||
{
|
||||
x = y = -1;
|
||||
if (!isActiveAndEnabled) return false;
|
||||
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(area, screenPos, null, out Vector2 local)) return false;
|
||||
// area 的 pivot 在下方中央
|
||||
Vector2 p = local + new Vector2(Width / 2, 0);
|
||||
const float step = CellSize + Spacing;
|
||||
int cx = Mathf.FloorToInt(p.x / step);
|
||||
int cy = Mathf.FloorToInt(p.y / step);
|
||||
if (!InBounds(cx, cy)) return false;
|
||||
if (p.x - cx * step > CellSize || p.y - cy * step > CellSize) return false;
|
||||
x = cx;
|
||||
y = cy;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Resources/Sprites 的圖片(快取)
|
||||
public static class Sprites
|
||||
{
|
||||
private static readonly System.Collections.Generic.Dictionary<string, Sprite> cache =
|
||||
new System.Collections.Generic.Dictionary<string, Sprite>();
|
||||
|
||||
public static Sprite Get(string name)
|
||||
{
|
||||
if (!cache.TryGetValue(name, out var s))
|
||||
{
|
||||
s = Resources.Load<Sprite>("Sprites/" + name);
|
||||
if (s == null) Debug.LogWarning("[Sprites] 找不到 " + name);
|
||||
cache[name] = s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d019d349bdba3bd4da6179077b905f3d
|
||||
@@ -0,0 +1,91 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem.EnhancedTouch;
|
||||
using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;
|
||||
using TouchPhase = UnityEngine.InputSystem.TouchPhase;
|
||||
|
||||
// 一根手指在本幀的狀態
|
||||
public struct GridTouch
|
||||
{
|
||||
public int fingerId;
|
||||
public Vector2 position;
|
||||
public bool began; // 本幀新按下
|
||||
public bool ended; // 本幀放開 / 取消
|
||||
public int x, y; // 所在格子,不在格子上為 -1
|
||||
public double pressAge; // 按下事件距今幾秒(用來回推精確的按下時間)
|
||||
|
||||
public bool OnCell => x >= 0;
|
||||
}
|
||||
|
||||
// 格子的觸控輸入(EnhancedTouch:同一幀內按下又放開的快速點擊也不會漏掉)
|
||||
// - IgnoreCurrentTouches 之前就按著的手指會被忽略(換畫面時)
|
||||
// - 按下時若最上層是面板、按鈕等 UI,這根手指直到放開都不會送到格子(防穿透)
|
||||
// - 編輯器裡用滑鼠模擬觸控
|
||||
public class GridInput
|
||||
{
|
||||
private readonly Grid grid;
|
||||
private readonly HashSet<int> ignored = new HashSet<int>();
|
||||
private readonly List<GridTouch> touches = new List<GridTouch>();
|
||||
|
||||
// 按下事件最多回推的秒數(避免掉幀時判定被推太遠)
|
||||
private const double MaxPressAge = 0.1;
|
||||
|
||||
public GridInput(Grid grid)
|
||||
{
|
||||
this.grid = grid;
|
||||
EnhancedTouchSupport.Enable();
|
||||
#if UNITY_EDITOR
|
||||
TouchSimulation.Enable();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void IgnoreCurrentTouches()
|
||||
{
|
||||
foreach (var t in Touch.activeTouches)
|
||||
ignored.Add(t.touchId);
|
||||
}
|
||||
|
||||
// blocked = true 時(例如開著對話框)所有新的觸控都不送到格子
|
||||
public List<GridTouch> Poll(bool blocked = false)
|
||||
{
|
||||
touches.Clear();
|
||||
double now = Time.realtimeSinceStartupAsDouble;
|
||||
|
||||
foreach (var t in Touch.activeTouches)
|
||||
{
|
||||
int id = t.touchId;
|
||||
TouchPhase phase = t.phase;
|
||||
bool ended = phase == TouchPhase.Ended || phase == TouchPhase.Canceled;
|
||||
bool began = phase == TouchPhase.Began;
|
||||
|
||||
if (began && (blocked || UIHitTest.IsBlocked(t.screenPosition)))
|
||||
ignored.Add(id);
|
||||
|
||||
if (ignored.Contains(id))
|
||||
{
|
||||
if (ended) ignored.Remove(id);
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector2 pos = t.screenPosition;
|
||||
if (ended)
|
||||
{
|
||||
touches.Add(new GridTouch { fingerId = id, ended = true, x = -1, y = -1, position = pos });
|
||||
continue;
|
||||
}
|
||||
|
||||
grid.CellAt(pos, out int x, out int y);
|
||||
double age = began ? System.Math.Min(MaxPressAge, System.Math.Max(0, now - t.startTime)) : 0;
|
||||
touches.Add(new GridTouch { fingerId = id, position = pos, began = began, x = x, y = y, pressAge = age });
|
||||
}
|
||||
return touches;
|
||||
}
|
||||
|
||||
// 本幀是否有新的點擊(任意位置,結算畫面「點擊繼續」用)
|
||||
public static bool AnyNewTap()
|
||||
{
|
||||
foreach (var t in Touch.activeTouches)
|
||||
if (t.phase == TouchPhase.Began) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58c9f43e3bbee1041b9972c39d2cf5cb
|
||||
@@ -0,0 +1,79 @@
|
||||
using UnityEngine;
|
||||
|
||||
// 以音訊 DSP 時鐘為準的歌曲時間(秒)
|
||||
// AudioSettings.dspTime 在手機上是以音訊 buffer 為單位跳動,
|
||||
// 這裡用 realtime 在兩次跳動之間補間,並保證時間單調遞增
|
||||
public static class SongClock
|
||||
{
|
||||
public static bool Running { get; private set; }
|
||||
public static bool Paused { get; private set; }
|
||||
|
||||
private static double dspStart;
|
||||
private static double lastDsp;
|
||||
private static double lastDspRealtime;
|
||||
private static double lastReturned;
|
||||
private static double offsetSec;
|
||||
private static double pausedAt;
|
||||
|
||||
// 補間最多往前推 0.1 秒,避免音訊卡住時畫面跑太快
|
||||
private const double MaxExtrapolation = 0.1;
|
||||
|
||||
// applyOffset = false:不套用延遲補償(校正量測時使用)
|
||||
public static void Begin(double dspStartTime, bool applyOffset = true)
|
||||
{
|
||||
dspStart = dspStartTime;
|
||||
lastDsp = AudioSettings.dspTime;
|
||||
lastDspRealtime = Time.realtimeSinceStartupAsDouble;
|
||||
lastReturned = double.MinValue;
|
||||
offsetSec = applyOffset ? PlayerPrefs.GetInt(Prefs.AudioOffsetMs, 0) / 1000.0 : 0;
|
||||
Running = true;
|
||||
Paused = false;
|
||||
}
|
||||
|
||||
// 暫停:時間停在目前的值(音符不會過期),以 Resume 接續
|
||||
public static void Pause()
|
||||
{
|
||||
if (!Running || Paused) return;
|
||||
pausedAt = Now;
|
||||
Paused = true;
|
||||
}
|
||||
|
||||
// 接續:音訊的 audioPos 秒在 DSP 時間 dspAt 播出(延遲補償沿用原本的值)
|
||||
public static void Resume(double audioPos, double dspAt)
|
||||
{
|
||||
double offset = offsetSec;
|
||||
Begin(dspAt - audioPos, false);
|
||||
offsetSec = offset;
|
||||
}
|
||||
|
||||
public static double PausedAt => pausedAt;
|
||||
|
||||
public static void Stop()
|
||||
{
|
||||
Running = false;
|
||||
Paused = false;
|
||||
}
|
||||
|
||||
// 目前歌曲時間;音樂開始前為負值
|
||||
public static double Now
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Running) return 0;
|
||||
if (Paused) return pausedAt;
|
||||
|
||||
double dsp = AudioSettings.dspTime;
|
||||
double real = Time.realtimeSinceStartupAsDouble;
|
||||
if (dsp != lastDsp)
|
||||
{
|
||||
lastDsp = dsp;
|
||||
lastDspRealtime = real;
|
||||
}
|
||||
|
||||
double t = lastDsp + System.Math.Min(real - lastDspRealtime, MaxExtrapolation) - dspStart - offsetSec;
|
||||
if (t < lastReturned) t = lastReturned;
|
||||
lastReturned = t;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 352b164fefd8c6b45bb274076fffc604
|
||||
Reference in new issue
Block a user