com.amanotes.magictilescore 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +240 -0
- package/CHANGELOG.md.meta +7 -0
- package/Docs/Class-Hierarchy.md +729 -0
- package/Docs/Class-Hierarchy.md.meta +7 -0
- package/Docs/Component-Architecture.md +43 -0
- package/Docs/Component-Architecture.md.meta +7 -0
- package/Docs/File-Structure.md +327 -0
- package/Docs/File-Structure.md.meta +7 -0
- package/Docs/Game-Architecture.md +41 -0
- package/Docs/Game-Architecture.md.meta +7 -0
- package/Docs/Input-System-Guide.md +419 -0
- package/Docs/Input-System-Guide.md.meta +7 -0
- package/Docs/Knot-System-Guide.md +309 -0
- package/Docs/Knot-System-Guide.md.meta +7 -0
- package/Docs/Meta-System-Guide.md +249 -0
- package/Docs/Meta-System-Guide.md.meta +7 -0
- package/Docs/New-Game-Checklist.md +102 -0
- package/Docs/New-Game-Checklist.md.meta +7 -0
- package/Docs/README.md +37 -0
- package/Docs/README.md.meta +7 -0
- package/Docs/RhythmCore-Architecture.md +373 -0
- package/Docs/RhythmCore-Architecture.md.meta +7 -0
- package/Docs/RhythmCore-Customize-Guide.md +391 -0
- package/Docs/RhythmCore-Customize-Guide.md.meta +7 -0
- package/Docs/Understanding-Rhythm-Core.md +483 -0
- package/Docs/Understanding-Rhythm-Core.md.meta +7 -0
- package/Docs/VisualWarp-System-Guide.md +377 -0
- package/Docs/VisualWarp-System-Guide.md.meta +7 -0
- package/Docs/Widget2D-System-Guide.md +450 -0
- package/Docs/Widget2D-System-Guide.md.meta +7 -0
- package/Docs.meta +8 -0
- package/Editor/AdjustHueEditor.cs +90 -0
- package/Editor/AdjustHueEditor.cs.meta +11 -0
- package/Editor/ClassInstanceDrawer.cs +256 -0
- package/Editor/ClassInstanceDrawer.cs.meta +11 -0
- package/Editor/CollapsibleGroupEditor.cs +142 -0
- package/Editor/CollapsibleGroupEditor.cs.meta +11 -0
- package/Editor/ListSongNoteEditor.cs +317 -0
- package/Editor/ListSongNoteEditor.cs.meta +11 -0
- package/Editor/MagicTilesCore.Editor.asmdef +20 -0
- package/Editor/MagicTilesCore.Editor.asmdef.meta +7 -0
- package/Editor/MetaLogicDrawer.cs +488 -0
- package/Editor/MetaLogicDrawer.cs.meta +11 -0
- package/Editor/RhythmContextEditor.EditorDrawer.cs +46 -0
- package/Editor/RhythmContextEditor.EditorDrawer.cs.meta +3 -0
- package/Editor/RhythmContextEditor.cs +587 -0
- package/Editor/RhythmContextEditor.cs.meta +3 -0
- package/Editor/RhythmGameEditor.cs +45 -0
- package/Editor/RhythmGameEditor.cs.meta +11 -0
- package/Editor/RhythmTileEditor.cs +93 -0
- package/Editor/RhythmTileEditor.cs.meta +11 -0
- package/Editor/TagConfigDrawer.cs +30 -0
- package/Editor/TagConfigDrawer.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/LICENSE.md +7 -0
- package/LICENSE.md.meta +7 -0
- package/README.md +88 -0
- package/README.md.meta +7 -0
- package/Runtime/AssemblyInfo.cs +4 -0
- package/Runtime/AssemblyInfo.cs.meta +11 -0
- package/Runtime/Input/Base/BaseTileInput.cs +44 -0
- package/Runtime/Input/Base/BaseTileInput.cs.meta +11 -0
- package/Runtime/Input/Base/IInputHandler.cs +11 -0
- package/Runtime/Input/Base/IInputHandler.cs.meta +11 -0
- package/Runtime/Input/Base/InputData.cs +94 -0
- package/Runtime/Input/Base/InputData.cs.meta +3 -0
- package/Runtime/Input/Base/InputDirection.cs +17 -0
- package/Runtime/Input/Base/InputDirection.cs.meta +3 -0
- package/Runtime/Input/Base/InputPhase.cs +4 -0
- package/Runtime/Input/Base/InputPhase.cs.meta +3 -0
- package/Runtime/Input/Base.meta +3 -0
- package/Runtime/Input/Components/DragInput.cs +44 -0
- package/Runtime/Input/Components/DragInput.cs.meta +11 -0
- package/Runtime/Input/Components/HoldInput.cs +75 -0
- package/Runtime/Input/Components/HoldInput.cs.meta +12 -0
- package/Runtime/Input/Components/SwipeInput.cs +45 -0
- package/Runtime/Input/Components/SwipeInput.cs.meta +12 -0
- package/Runtime/Input/Components/TouchInput.cs +31 -0
- package/Runtime/Input/Components/TouchInput.cs.meta +11 -0
- package/Runtime/Input/Components.meta +8 -0
- package/Runtime/Input.meta +8 -0
- package/Runtime/MagicTilesCore.asmdef +24 -0
- package/Runtime/MagicTilesCore.asmdef.meta +7 -0
- package/Runtime/MoodChange/AdjustHue.ComponentInfo.cs +12 -0
- package/Runtime/MoodChange/AdjustHue.ComponentInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.MaterialInfo.cs +115 -0
- package/Runtime/MoodChange/AdjustHue.MaterialInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.ParticleSystemInfo.cs +36 -0
- package/Runtime/MoodChange/AdjustHue.ParticleSystemInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.SpriteRendererInfo.cs +28 -0
- package/Runtime/MoodChange/AdjustHue.SpriteRendererInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.TrailRendererInfo.cs +37 -0
- package/Runtime/MoodChange/AdjustHue.TrailRendererInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.cs +219 -0
- package/Runtime/MoodChange/AdjustHue.cs.meta +11 -0
- package/Runtime/MoodChange/ColorHueExtensions.cs +227 -0
- package/Runtime/MoodChange/ColorHueExtensions.cs.meta +3 -0
- package/Runtime/MoodChange/HueCache.cs +167 -0
- package/Runtime/MoodChange/HueCache.cs.meta +11 -0
- package/Runtime/MoodChange/MoodChange.cs +52 -0
- package/Runtime/MoodChange/MoodChange.cs.meta +3 -0
- package/Runtime/MoodChange.meta +3 -0
- package/Runtime/Physics/TriggerCallback.cs +21 -0
- package/Runtime/Physics/TriggerCallback.cs.meta +3 -0
- package/Runtime/Physics.meta +8 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.cs +153 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.cs.meta +11 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.prefab +145 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.prefab.meta +7 -0
- package/Runtime/Preset/AudioSourcePlayer.meta +8 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.cs +22 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.cs.meta +11 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.prefab +188 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.prefab.meta +7 -0
- package/Runtime/Preset/AudioTimeText.meta +8 -0
- package/Runtime/Preset/ParticleSystemPlayer/ParticleSystemPlayer.cs +32 -0
- package/Runtime/Preset/ParticleSystemPlayer/ParticleSystemPlayer.cs.meta +11 -0
- package/Runtime/Preset/ParticleSystemPlayer.meta +8 -0
- package/Runtime/Preset/RendererAlpha.cs +56 -0
- package/Runtime/Preset/RendererAlpha.cs.meta +11 -0
- package/Runtime/Preset/ScoreText/ScoreText.anim +198 -0
- package/Runtime/Preset/ScoreText/ScoreText.anim.meta +8 -0
- package/Runtime/Preset/ScoreText/ScoreText.cs +32 -0
- package/Runtime/Preset/ScoreText/ScoreText.cs.meta +11 -0
- package/Runtime/Preset/ScoreText/ScoreText_2D.prefab +170 -0
- package/Runtime/Preset/ScoreText/ScoreText_2D.prefab.meta +7 -0
- package/Runtime/Preset/ScoreText/ScoreText_3D.prefab +206 -0
- package/Runtime/Preset/ScoreText/ScoreText_3D.prefab.meta +7 -0
- package/Runtime/Preset/ScoreText.meta +8 -0
- package/Runtime/Preset/StartHint/StartHint.cs +26 -0
- package/Runtime/Preset/StartHint/StartHint.cs.meta +3 -0
- package/Runtime/Preset/StartHint.meta +8 -0
- package/Runtime/Preset/WowText/WowText.cs +38 -0
- package/Runtime/Preset/WowText/WowText.cs.meta +3 -0
- package/Runtime/Preset/WowText.meta +8 -0
- package/Runtime/Preset.meta +8 -0
- package/Runtime/Rhythm/Components/Controls.meta +8 -0
- package/Runtime/Rhythm/Components/Helper/CameraFollow.cs +28 -0
- package/Runtime/Rhythm/Components/Helper/CameraFollow.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper/MeshSpriteSorter.cs +89 -0
- package/Runtime/Rhythm/Components/Helper/MeshSpriteSorter.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper/RecycleLayoutZ.cs +74 -0
- package/Runtime/Rhythm/Components/Helper/RecycleLayoutZ.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper.meta +8 -0
- package/Runtime/Rhythm/Components.meta +8 -0
- package/Runtime/Rhythm/Core/GameMode.cs +10 -0
- package/Runtime/Rhythm/Core/GameMode.cs.meta +3 -0
- package/Runtime/Rhythm/Core/IAudioPlayer.cs +16 -0
- package/Runtime/Rhythm/Core/IAudioPlayer.cs.meta +3 -0
- package/Runtime/Rhythm/Core/IRhythmBehaviour.cs +10 -0
- package/Runtime/Rhythm/Core/IRhythmBehaviour.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmBehaviour.cs +57 -0
- package/Runtime/Rhythm/Core/RhythmBehaviour.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmDebug.cs +48 -0
- package/Runtime/Rhythm/Core/RhythmDebug.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmGameT.cs +323 -0
- package/Runtime/Rhythm/Core/RhythmGameT.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmMatch.cs +65 -0
- package/Runtime/Rhythm/Core/RhythmMatch.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmTile.cs +77 -0
- package/Runtime/Rhythm/Core/RhythmTile.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmTileHandler.cs +59 -0
- package/Runtime/Rhythm/Core/RhythmTileHandler.cs.meta +3 -0
- package/Runtime/Rhythm/Core.meta +8 -0
- package/Runtime/Rhythm/Extensions/CollectionExtensions.cs +120 -0
- package/Runtime/Rhythm/Extensions/CollectionExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/ColliderExtensions.cs +27 -0
- package/Runtime/Rhythm/Extensions/ColliderExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/GameHandlerExtensions.cs +56 -0
- package/Runtime/Rhythm/Extensions/GameHandlerExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/GameObjectExtensions.cs +61 -0
- package/Runtime/Rhythm/Extensions/GameObjectExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/InputDirectionExtensions.cs +76 -0
- package/Runtime/Rhythm/Extensions/InputDirectionExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/MTCListExtensions.cs +127 -0
- package/Runtime/Rhythm/Extensions/MTCListExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/MeshRendererExtensions.cs +81 -0
- package/Runtime/Rhythm/Extensions/MeshRendererExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/ParticleSystemExtensions.cs +54 -0
- package/Runtime/Rhythm/Extensions/ParticleSystemExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions.meta +8 -0
- package/Runtime/Rhythm/Game/MTCSongAutoStart.cs +40 -0
- package/Runtime/Rhythm/Game/MTCSongAutoStart.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmConfig.cs +68 -0
- package/Runtime/Rhythm/Game/RhythmConfig.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Api.cs +533 -0
- package/Runtime/Rhythm/Game/RhythmContext.Api.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Dev.cs +121 -0
- package/Runtime/Rhythm/Game/RhythmContext.Dev.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Initialization.cs +114 -0
- package/Runtime/Rhythm/Game/RhythmContext.Initialization.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Runtime.cs +126 -0
- package/Runtime/Rhythm/Game/RhythmContext.Runtime.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.State.cs +221 -0
- package/Runtime/Rhythm/Game/RhythmContext.State.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Tile.cs +90 -0
- package/Runtime/Rhythm/Game/RhythmContext.Tile.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.TimeMachine.cs +315 -0
- package/Runtime/Rhythm/Game/RhythmContext.TimeMachine.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.cs +312 -0
- package/Runtime/Rhythm/Game/RhythmContext.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContextExtensions.cs +91 -0
- package/Runtime/Rhythm/Game/RhythmContextExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Game/Tile/ITileProgress.cs +7 -0
- package/Runtime/Rhythm/Game/Tile/ITileProgress.cs.meta +3 -0
- package/Runtime/Rhythm/Game/Tile/TileContext.cs +194 -0
- package/Runtime/Rhythm/Game/Tile/TileContext.cs.meta +11 -0
- package/Runtime/Rhythm/Game/Tile.meta +3 -0
- package/Runtime/Rhythm/Game.meta +3 -0
- package/Runtime/Rhythm/Math/Parabol.cs +35 -0
- package/Runtime/Rhythm/Math/Parabol.cs.meta +11 -0
- package/Runtime/Rhythm/Math.meta +8 -0
- package/Runtime/Rhythm/System/Event/GameEvent.cs +82 -0
- package/Runtime/Rhythm/System/Event/GameEvent.cs.meta +3 -0
- package/Runtime/Rhythm/System/Event.meta +8 -0
- package/Runtime/Rhythm/System/Meta/MetaLogic.cs +121 -0
- package/Runtime/Rhythm/System/Meta/MetaLogic.cs.meta +11 -0
- package/Runtime/Rhythm/System/Meta/VisualSpeedMeta.cs +132 -0
- package/Runtime/Rhythm/System/Meta/VisualSpeedMeta.cs.meta +11 -0
- package/Runtime/Rhythm/System/Meta.meta +8 -0
- package/Runtime/Rhythm/System/SongData/ListSongNote.cs +45 -0
- package/Runtime/Rhythm/System/SongData/ListSongNote.cs.meta +3 -0
- package/Runtime/Rhythm/System/SongData.meta +8 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.State.cs +22 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.State.cs.meta +11 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.cs +138 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.cs.meta +11 -0
- package/Runtime/Rhythm/System/StateMachine.meta +8 -0
- package/Runtime/Rhythm/System/TimeKnot/ListTimeKnots.cs +135 -0
- package/Runtime/Rhythm/System/TimeKnot/ListTimeKnots.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeKnot.meta +8 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeInterpolator.cs +365 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeInterpolator.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeMarker.cs +107 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeMarker.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeNode.cs +14 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeNode.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeSpanNode.cs +21 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeSpanNode.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.ZLaneSpeed.cs +28 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.ZLaneSpeed.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.cs +131 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeMachine.meta +8 -0
- package/Runtime/Rhythm/System/VisualKnot/VisualKnotLogic.cs +160 -0
- package/Runtime/Rhythm/System/VisualKnot/VisualKnotLogic.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualKnot.meta +8 -0
- package/Runtime/Rhythm/System/VisualWarp/IVisualWarp.cs +10 -0
- package/Runtime/Rhythm/System/VisualWarp/IVisualWarp.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualWarp/LinearVisualWarp.cs +27 -0
- package/Runtime/Rhythm/System/VisualWarp/LinearVisualWarp.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualWarp.meta +8 -0
- package/Runtime/Rhythm/System.meta +8 -0
- package/Runtime/Rhythm.meta +8 -0
- package/Runtime.meta +8 -0
- package/package.json +12 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
|
|
3
|
+
namespace Amanotes.MagicTilesCore
|
|
4
|
+
{
|
|
5
|
+
public static class ColorHueExtensions
|
|
6
|
+
{
|
|
7
|
+
private static float GetHue01(Color c)
|
|
8
|
+
{
|
|
9
|
+
float r = c.r, g = c.g, b = c.b;
|
|
10
|
+
|
|
11
|
+
var max = Mathf.Max(r, Mathf.Max(g, b));
|
|
12
|
+
var min = Mathf.Min(r, Mathf.Min(g, b));
|
|
13
|
+
var delta = max - min;
|
|
14
|
+
|
|
15
|
+
if (delta <= 0.000001f)
|
|
16
|
+
return 0f;
|
|
17
|
+
|
|
18
|
+
float h;
|
|
19
|
+
|
|
20
|
+
if (Mathf.Approximately(max, r))
|
|
21
|
+
h = (g - b) / delta;
|
|
22
|
+
else if (Mathf.Approximately(max, g))
|
|
23
|
+
h = 2f + (b - r) / delta;
|
|
24
|
+
else
|
|
25
|
+
h = 4f + (r - g) / delta;
|
|
26
|
+
|
|
27
|
+
h /= 6f;
|
|
28
|
+
if (h < 0f) h += 1f;
|
|
29
|
+
|
|
30
|
+
return h;
|
|
31
|
+
}
|
|
32
|
+
private static Color WithHue01(Color c, float newHue)
|
|
33
|
+
{
|
|
34
|
+
Color.RGBToHSV(c, out _, out var s, out var v);
|
|
35
|
+
var final = Color.HSVToRGB(newHue, s, v);
|
|
36
|
+
final.a = c.a;
|
|
37
|
+
return final;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
public static int GetHue(this Color c) => Mathf.RoundToInt(GetHue01(c) * 255);
|
|
42
|
+
public static Color WithHue(this Color c, int newHue) => WithHue01(c, newHue/255f);
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// Material support
|
|
46
|
+
public static void SetHue(this Material m, Color c, int nameID, int customHue = -1)
|
|
47
|
+
{
|
|
48
|
+
if (m == null) return;
|
|
49
|
+
var c2 = c;
|
|
50
|
+
if (customHue != -1) c2 = c.WithHue(customHue);
|
|
51
|
+
m.SetColor(nameID, c2);
|
|
52
|
+
}
|
|
53
|
+
public static void SetHue(this Material m,int nameID, int hue)
|
|
54
|
+
{
|
|
55
|
+
if (m == null) return;
|
|
56
|
+
|
|
57
|
+
var colorInfo = HueCache.GetOrCreateColorInfo(m);
|
|
58
|
+
if (!colorInfo.isValid)
|
|
59
|
+
{
|
|
60
|
+
colorInfo.CacheColor(m.GetColor(nameID));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
m.SetColor(nameID, colorInfo.GetColorWithNewHue(hue));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public static int GetHue(this Material m,int nameID)
|
|
67
|
+
=> m == null ? 0 : m.GetColor(nameID).GetHue();
|
|
68
|
+
public static Color WithHue(this Material m,int nameID, int hue)
|
|
69
|
+
=> m == null ? Color.white : m.GetColor(nameID).WithHue(hue);
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// Gradient Support
|
|
73
|
+
public static int GetHue(this Gradient g)
|
|
74
|
+
{
|
|
75
|
+
if (g == null) return 0;
|
|
76
|
+
var keys = g.colorKeys;
|
|
77
|
+
if (keys == null || keys.Length == 0) return 0;
|
|
78
|
+
return keys[0].color.GetHue();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public static Gradient WithHue(this Gradient g, int newHue)
|
|
82
|
+
{
|
|
83
|
+
if (g == null) return null;
|
|
84
|
+
|
|
85
|
+
var keysC = g.colorKeys;
|
|
86
|
+
var keysA = g.alphaKeys;
|
|
87
|
+
|
|
88
|
+
for (var i = 0; i < keysC.Length; i++)
|
|
89
|
+
{
|
|
90
|
+
var c = keysC[i].color;
|
|
91
|
+
keysC[i].color = c.WithHue(newHue);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
g.SetKeys(keysC, keysA);
|
|
95
|
+
return g;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Particle effect support
|
|
99
|
+
// for (var i = 0; i < particles.Count; i++)
|
|
100
|
+
// {
|
|
101
|
+
// particles[i].startColor = c;
|
|
102
|
+
// }
|
|
103
|
+
|
|
104
|
+
public static void SetHue(this ParticleSystem ps, int newHue)
|
|
105
|
+
{
|
|
106
|
+
if (ps == null) return;
|
|
107
|
+
|
|
108
|
+
var colorInfo = HueCache.GetOrCreateColorInfo(ps);
|
|
109
|
+
var main = ps.main;
|
|
110
|
+
var startColor = main.startColor;
|
|
111
|
+
|
|
112
|
+
switch (startColor.mode)
|
|
113
|
+
{
|
|
114
|
+
case ParticleSystemGradientMode.Color:
|
|
115
|
+
if (!colorInfo.isValid)
|
|
116
|
+
{
|
|
117
|
+
colorInfo.CacheColor(startColor.color);
|
|
118
|
+
}
|
|
119
|
+
startColor.color = colorInfo.GetColorWithNewHue(newHue);
|
|
120
|
+
break;
|
|
121
|
+
case ParticleSystemGradientMode.Gradient:
|
|
122
|
+
startColor.gradient = startColor.gradient.WithHue(newHue);
|
|
123
|
+
break;
|
|
124
|
+
case ParticleSystemGradientMode.TwoColors:
|
|
125
|
+
startColor.colorMin = startColor.colorMin.WithHue(newHue);
|
|
126
|
+
startColor.colorMax = startColor.colorMax.WithHue(newHue);
|
|
127
|
+
break;
|
|
128
|
+
case ParticleSystemGradientMode.TwoGradients:
|
|
129
|
+
startColor.gradientMin = startColor.gradientMin.WithHue(newHue);
|
|
130
|
+
startColor.gradientMax = startColor.gradientMax.WithHue(newHue);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
main.startColor = startColor;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public static int GetHue(this ParticleSystem ps)
|
|
138
|
+
{
|
|
139
|
+
if (ps == null) return 0;
|
|
140
|
+
var sc = ps.main.startColor;
|
|
141
|
+
|
|
142
|
+
switch (sc.mode)
|
|
143
|
+
{
|
|
144
|
+
case ParticleSystemGradientMode.Color:
|
|
145
|
+
return sc.color.GetHue();
|
|
146
|
+
case ParticleSystemGradientMode.Gradient:
|
|
147
|
+
return sc.gradient.GetHue();
|
|
148
|
+
case ParticleSystemGradientMode.TwoColors:
|
|
149
|
+
return sc.colorMax.GetHue();
|
|
150
|
+
case ParticleSystemGradientMode.TwoGradients:
|
|
151
|
+
return sc.gradientMax.GetHue();
|
|
152
|
+
default:
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Support Sprite Renderer
|
|
158
|
+
public static int GetHue(this SpriteRenderer sr)
|
|
159
|
+
{
|
|
160
|
+
return sr == null ? 0 : sr.color.GetHue();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public static void SetHue(this SpriteRenderer sr, int newHue)
|
|
164
|
+
{
|
|
165
|
+
if (sr == null) return;
|
|
166
|
+
|
|
167
|
+
var colorInfo = HueCache.GetOrCreateColorInfo(sr);
|
|
168
|
+
if (!colorInfo.isValid)
|
|
169
|
+
{
|
|
170
|
+
colorInfo.CacheColor(sr.color);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
sr.color = colorInfo.GetColorWithNewHue(newHue);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public static Color WithHue(this SpriteRenderer sr, int newHue)
|
|
177
|
+
{
|
|
178
|
+
if (sr == null) return Color.white;
|
|
179
|
+
|
|
180
|
+
var colorInfo = HueCache.GetOrCreateColorInfo(sr);
|
|
181
|
+
if (!colorInfo.isValid)
|
|
182
|
+
{
|
|
183
|
+
colorInfo.CacheColor(sr.color);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
var c = colorInfo.GetColorWithNewHue(newHue);
|
|
187
|
+
sr.color = c;
|
|
188
|
+
return c;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// support TrailRenderer.colorGradient
|
|
192
|
+
public static int GetHue(this TrailRenderer tr)
|
|
193
|
+
{
|
|
194
|
+
if (tr == null) return 0;
|
|
195
|
+
return tr.colorGradient.GetHue();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public static void SetHue(this TrailRenderer tr, int newHue)
|
|
199
|
+
{
|
|
200
|
+
if (tr == null) return;
|
|
201
|
+
|
|
202
|
+
var colorInfo = HueCache.GetOrCreateColorInfo(tr);
|
|
203
|
+
if (!colorInfo.isValid)
|
|
204
|
+
{
|
|
205
|
+
// For TrailRenderer, we cache the first color key of the gradient
|
|
206
|
+
var gradient = tr.colorGradient;
|
|
207
|
+
if (gradient != null && gradient.colorKeys.Length > 0)
|
|
208
|
+
{
|
|
209
|
+
colorInfo.CacheColor(gradient.colorKeys[0].color);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var g = tr.colorGradient;
|
|
214
|
+
g.WithHue(newHue);
|
|
215
|
+
tr.colorGradient = g;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public static Gradient WithHue(this TrailRenderer tr, int newHue)
|
|
219
|
+
{
|
|
220
|
+
if (tr == null) return null;
|
|
221
|
+
var g = tr.colorGradient;
|
|
222
|
+
g.WithHue(newHue);
|
|
223
|
+
tr.colorGradient = g;
|
|
224
|
+
return g;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace Amanotes.MagicTilesCore
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Shared hue cache system to prevent color drift when applying hue changes multiple times.
|
|
8
|
+
/// Maps UnityEngine.Object instances to their original color information.
|
|
9
|
+
/// </summary>
|
|
10
|
+
public static class HueCache
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
/// Cached color information for a Unity object
|
|
14
|
+
/// </summary>
|
|
15
|
+
public class ColorInfo
|
|
16
|
+
{
|
|
17
|
+
public Color originalColorRGB;
|
|
18
|
+
public Vector3 originalHSV; // x=H, y=S, z=V
|
|
19
|
+
public float originalAlpha;
|
|
20
|
+
public bool isValid = false;
|
|
21
|
+
|
|
22
|
+
public void CacheColor(Color color)
|
|
23
|
+
{
|
|
24
|
+
if (isValid)
|
|
25
|
+
{
|
|
26
|
+
Debug.LogWarning($"CacheColor should happen once, previous: <{originalColorRGB}> --> {color}");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
originalColorRGB = color;
|
|
31
|
+
originalAlpha = color.a;
|
|
32
|
+
RGBToHSV(color, out float h, out float s, out float v);
|
|
33
|
+
originalHSV = new Vector3(h, s, v);
|
|
34
|
+
isValid = true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public Color GetColorWithNewHue(int hue)
|
|
38
|
+
{
|
|
39
|
+
if (!isValid)
|
|
40
|
+
{
|
|
41
|
+
var c = HSVToRGB(hue, 0.9f, 0.9f, 1f);
|
|
42
|
+
Debug.LogWarning($"Color not init: {hue}, default set to {c}!");
|
|
43
|
+
CacheColor(c);
|
|
44
|
+
|
|
45
|
+
return c;
|
|
46
|
+
}
|
|
47
|
+
var newHue = (hue / 255.0f) * 360.0f;
|
|
48
|
+
return HSVToRGB(newHue, originalHSV.y, originalHSV.z, originalAlpha);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Cache mapping UnityEngine.Object -> ColorInfo
|
|
53
|
+
private static readonly Dictionary<Object, ColorInfo> _colorCache = new Dictionary<Object, ColorInfo>();
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
/// Gets cached color info for a Unity object, creating it if it doesn't exist
|
|
57
|
+
/// </summary>
|
|
58
|
+
public static ColorInfo GetOrCreateColorInfo(Object unityObject)
|
|
59
|
+
{
|
|
60
|
+
if (unityObject == null) return null;
|
|
61
|
+
if (_colorCache.TryGetValue(unityObject, out var colorInfo)) return colorInfo;
|
|
62
|
+
|
|
63
|
+
colorInfo = new ColorInfo();
|
|
64
|
+
_colorCache[unityObject] = colorInfo;
|
|
65
|
+
return colorInfo;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// <summary>
|
|
69
|
+
/// Clears cached color info for a specific object
|
|
70
|
+
/// </summary>
|
|
71
|
+
public static void ClearCache(Object unityObject)
|
|
72
|
+
{
|
|
73
|
+
if (unityObject != null)
|
|
74
|
+
{
|
|
75
|
+
_colorCache.Remove(unityObject);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// <summary>
|
|
80
|
+
/// Clears all cached color information
|
|
81
|
+
/// </summary>
|
|
82
|
+
public static void ClearAllCache()
|
|
83
|
+
{
|
|
84
|
+
_colorCache.Clear();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// <summary>
|
|
88
|
+
/// Gets the number of cached objects
|
|
89
|
+
/// </summary>
|
|
90
|
+
public static int CacheCount => _colorCache.Count;
|
|
91
|
+
|
|
92
|
+
// HSV conversion methods (same as in AdjustHue for consistency)
|
|
93
|
+
private static void RGBToHSV(Color color, out float h, out float s, out float v)
|
|
94
|
+
{
|
|
95
|
+
float r = color.r;
|
|
96
|
+
float g = color.g;
|
|
97
|
+
float b = color.b;
|
|
98
|
+
|
|
99
|
+
float max = Mathf.Max(r, Mathf.Max(g, b));
|
|
100
|
+
float min = Mathf.Min(r, Mathf.Min(g, b));
|
|
101
|
+
float delta = max - min;
|
|
102
|
+
|
|
103
|
+
// Value
|
|
104
|
+
v = max;
|
|
105
|
+
|
|
106
|
+
// Saturation
|
|
107
|
+
s = (max != 0) ? (delta / max) : 0;
|
|
108
|
+
|
|
109
|
+
// Hue
|
|
110
|
+
if (delta == 0)
|
|
111
|
+
{
|
|
112
|
+
h = 0; // Undefined, but we'll use 0
|
|
113
|
+
}
|
|
114
|
+
else if (max == r)
|
|
115
|
+
{
|
|
116
|
+
h = ((g - b) / delta) % 6;
|
|
117
|
+
}
|
|
118
|
+
else if (max == g)
|
|
119
|
+
{
|
|
120
|
+
h = (b - r) / delta + 2;
|
|
121
|
+
}
|
|
122
|
+
else // max == b
|
|
123
|
+
{
|
|
124
|
+
h = (r - g) / delta + 4;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
h *= 60;
|
|
128
|
+
if (h < 0) h += 360;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private static Color HSVToRGB(float h, float s, float v, float a)
|
|
132
|
+
{
|
|
133
|
+
float c = v * s;
|
|
134
|
+
float x = c * (1 - Mathf.Abs((h / 60) % 2 - 1));
|
|
135
|
+
float m = v - c;
|
|
136
|
+
|
|
137
|
+
float r, g, b;
|
|
138
|
+
|
|
139
|
+
if (h >= 0 && h < 60)
|
|
140
|
+
{
|
|
141
|
+
r = c; g = x; b = 0;
|
|
142
|
+
}
|
|
143
|
+
else if (h >= 60 && h < 120)
|
|
144
|
+
{
|
|
145
|
+
r = x; g = c; b = 0;
|
|
146
|
+
}
|
|
147
|
+
else if (h >= 120 && h < 180)
|
|
148
|
+
{
|
|
149
|
+
r = 0; g = c; b = x;
|
|
150
|
+
}
|
|
151
|
+
else if (h >= 180 && h < 240)
|
|
152
|
+
{
|
|
153
|
+
r = 0; g = x; b = c;
|
|
154
|
+
}
|
|
155
|
+
else if (h >= 240 && h < 300)
|
|
156
|
+
{
|
|
157
|
+
r = x; g = 0; b = c;
|
|
158
|
+
}
|
|
159
|
+
else // h >= 300 && h < 360
|
|
160
|
+
{
|
|
161
|
+
r = c; g = 0; b = x;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return new Color(r + m, g + m, b + m, a);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace Amanotes.MagicTilesCore
|
|
5
|
+
{
|
|
6
|
+
public static class MoodChange
|
|
7
|
+
{
|
|
8
|
+
[Serializable] public abstract class ColorAnim
|
|
9
|
+
{
|
|
10
|
+
[NonSerialized] protected Color fromColor;
|
|
11
|
+
[NonSerialized] protected Color targetColor;
|
|
12
|
+
|
|
13
|
+
public virtual void SetTargetHue(int hue)
|
|
14
|
+
{
|
|
15
|
+
fromColor = GetCurrentColor();
|
|
16
|
+
targetColor = fromColor.WithHue(hue);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
protected abstract Color GetCurrentColor();
|
|
20
|
+
public abstract void Refresh(float lerp);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[Serializable] public class MaterialColorAnim : ColorAnim
|
|
24
|
+
{
|
|
25
|
+
[SerializeField] private Material material;
|
|
26
|
+
[SerializeField] private string colorProp = "_Color";
|
|
27
|
+
[NonSerialized] private int colorNameID = -1;
|
|
28
|
+
|
|
29
|
+
protected override Color GetCurrentColor()
|
|
30
|
+
{
|
|
31
|
+
|
|
32
|
+
if (!Application.isPlaying || colorNameID == -1) colorNameID = Shader.PropertyToID(colorProp);
|
|
33
|
+
return material.GetColor(colorNameID);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public override void Refresh(float lerp)
|
|
37
|
+
{
|
|
38
|
+
if (!Application.isPlaying || colorNameID == -1) colorNameID = Shader.PropertyToID(colorProp);
|
|
39
|
+
material.SetColor(colorNameID, Color.Lerp(fromColor, targetColor, lerp));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[Serializable] public class FogColorAnim : ColorAnim
|
|
44
|
+
{
|
|
45
|
+
protected override Color GetCurrentColor() => RenderSettings.fogColor;
|
|
46
|
+
public override void Refresh(float lerp)
|
|
47
|
+
{
|
|
48
|
+
RenderSettings.fogColor = Color.Lerp(fromColor, targetColor, lerp);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using UnityEngine.Events;
|
|
4
|
+
|
|
5
|
+
namespace Amanotes.MagicTilesCore
|
|
6
|
+
{
|
|
7
|
+
[Serializable]
|
|
8
|
+
public class TriggerEvent : UnityEvent<string> { }
|
|
9
|
+
public class TriggerCallback : MonoBehaviour
|
|
10
|
+
{
|
|
11
|
+
[SerializeField] private string id = "";
|
|
12
|
+
[SerializeField] private string targetTag = "";
|
|
13
|
+
[SerializeField] private TriggerEvent OnTrigger;
|
|
14
|
+
|
|
15
|
+
private void OnTriggerEnter(Collider other)
|
|
16
|
+
{
|
|
17
|
+
if (!other.CompareTag(targetTag)) return;
|
|
18
|
+
OnTrigger?.Invoke(id ?? gameObject.name);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace Amanotes.MagicTilesCore
|
|
5
|
+
{
|
|
6
|
+
public class AudioSourcePlayer : RhythmBehaviour, IAudioPlayer
|
|
7
|
+
{
|
|
8
|
+
public AudioSource source;
|
|
9
|
+
public bool fakeMode => context?.fakeMode ?? false;
|
|
10
|
+
|
|
11
|
+
public override void Init()
|
|
12
|
+
{
|
|
13
|
+
context.audioPlayer = this;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public void Prepare()
|
|
17
|
+
{
|
|
18
|
+
if (!fakeMode && source != null)
|
|
19
|
+
{
|
|
20
|
+
source.playOnAwake = false;
|
|
21
|
+
source.loop = false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
sourceTime = 0f;
|
|
25
|
+
simulateTime = 0f;
|
|
26
|
+
_isPlaying = false;
|
|
27
|
+
_audioSpeed = 1f;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public void Play()
|
|
31
|
+
{
|
|
32
|
+
_isPlaying = true;
|
|
33
|
+
if (fakeMode) return;
|
|
34
|
+
|
|
35
|
+
if (source != null)
|
|
36
|
+
{
|
|
37
|
+
sourceTime = source.clip != null ? source.time : 0f;
|
|
38
|
+
simulateTime = 0;
|
|
39
|
+
source.Play();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public bool isPlaying => !fakeMode && source != null ? source.isPlaying : _isPlaying;
|
|
44
|
+
|
|
45
|
+
public void Pause()
|
|
46
|
+
{
|
|
47
|
+
_isPlaying = false;
|
|
48
|
+
if (fakeMode || source == null) return;
|
|
49
|
+
source.Pause();
|
|
50
|
+
sourceTime = source.clip != null ? source.time : 0f;
|
|
51
|
+
simulateTime = 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public void Seek(float time)
|
|
55
|
+
{
|
|
56
|
+
var duration = ((IAudioPlayer)this).audioDuration;
|
|
57
|
+
|
|
58
|
+
if (duration <= 0)
|
|
59
|
+
{
|
|
60
|
+
RhythmDebug.Log("Audio", $"AudioSourcePlayer.Seek: Cannot seek when audio duration is {duration}. Audio clip may not be loaded.");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (time < 0 || time > duration)
|
|
65
|
+
{
|
|
66
|
+
RhythmDebug.Log("Audio", $"AudioSourcePlayer.Seek: Invalid seek time {time:F3}s. Valid range is [0, {duration:F3}]s. Clamping to valid range.");
|
|
67
|
+
time = Mathf.Clamp(time, 0, duration);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (fakeMode)
|
|
71
|
+
{
|
|
72
|
+
sourceTime = time;
|
|
73
|
+
simulateTime = 0;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (source == null)
|
|
78
|
+
{
|
|
79
|
+
RhythmDebug.Log("Audio", "AudioSourcePlayer.Seek: AudioSource is null");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (source.clip == null)
|
|
84
|
+
{
|
|
85
|
+
RhythmDebug.Log("Audio", "AudioSourcePlayer.Seek: AudioSource.clip is null");
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Final validation against actual clip length
|
|
90
|
+
if (time >= source.clip.length)
|
|
91
|
+
{
|
|
92
|
+
RhythmDebug.Log("Audio", $"AudioSourcePlayer.Seek: Seek time {time:F3}s exceeds clip length {source.clip.length:F3}s. Clamping to clip length.");
|
|
93
|
+
time = source.clip.length-0.001f;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
try
|
|
97
|
+
{
|
|
98
|
+
source.time = time;
|
|
99
|
+
sourceTime = source.time;
|
|
100
|
+
simulateTime = time - sourceTime;
|
|
101
|
+
}
|
|
102
|
+
catch (System.Exception ex)
|
|
103
|
+
{
|
|
104
|
+
Debug.LogWarning("Audio --> " + $"AudioSourcePlayer.Seek: Failed to seek to time {time:F3}s / {source.clip.length}. Error: {ex.Message}");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private float sourceTime;
|
|
109
|
+
private float simulateTime;
|
|
110
|
+
private bool _isPlaying;
|
|
111
|
+
private float _audioSpeed = 1f;
|
|
112
|
+
|
|
113
|
+
private const float TIME_SYNC_THRESHOLD = 0.001f;
|
|
114
|
+
|
|
115
|
+
public float audioTime => sourceTime + simulateTime;
|
|
116
|
+
float IAudioPlayer.audioDuration => (!fakeMode && source != null && source.clip != null ? source.clip.length : 0f);
|
|
117
|
+
public float audioSpeed
|
|
118
|
+
{
|
|
119
|
+
get => !fakeMode && source != null ? source.pitch : _audioSpeed;
|
|
120
|
+
set
|
|
121
|
+
{
|
|
122
|
+
_audioSpeed = value;
|
|
123
|
+
if (!fakeMode && source != null)
|
|
124
|
+
{
|
|
125
|
+
source.pitch = value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
public void UpdateTime(float dt)
|
|
132
|
+
{
|
|
133
|
+
if (!isPlaying) return;
|
|
134
|
+
if (fakeMode)
|
|
135
|
+
{
|
|
136
|
+
sourceTime += dt;
|
|
137
|
+
simulateTime = 0;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (source != null && source.clip != null && Math.Abs(sourceTime - source.time) < TIME_SYNC_THRESHOLD)
|
|
142
|
+
{
|
|
143
|
+
simulateTime += dt;
|
|
144
|
+
}
|
|
145
|
+
else if (source != null && source.clip != null)
|
|
146
|
+
{
|
|
147
|
+
sourceTime = source.time;
|
|
148
|
+
simulateTime = 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
}
|