mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-23 18:15:13 +00:00
Timeline playback start clamping
This commit is contained in:
parent
d7a4239153
commit
799592860a
7 changed files with 55 additions and 14 deletions
Binary file not shown.
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
|
@ -2758,7 +2758,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 0, y: 0.5}
|
||||
m_AnchoredPosition: {x: 85, y: 0}
|
||||
m_AnchoredPosition: {x: 82.70001, y: 0}
|
||||
m_SizeDelta: {x: 35, y: 35}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!114 &678553526
|
||||
|
@ -5929,6 +5929,9 @@ MonoBehaviour:
|
|||
Screen: {fileID: 558010761}
|
||||
GridGameSelector: {fileID: 1154875943}
|
||||
Timeline: {fileID: 1861169747}
|
||||
NewBTN: {fileID: 1683100750}
|
||||
OpenBTN: {fileID: 0}
|
||||
SaveBTN: {fileID: 0}
|
||||
--- !u!114 &1423699438
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -5941,8 +5944,8 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: f86858990a87c764892672104bdaef1f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
level: {fileID: 4900000, guid: 4b7512c586e16a847a5b8490bf35e852, type: 3}
|
||||
music: {fileID: 8300000, guid: 92cf585c80f8fb843964e525aef1406c, type: 3}
|
||||
level: {fileID: 4900000, guid: cbe1a43c8ddc790498fde2e01e66d23e, type: 3}
|
||||
music: {fileID: 8300000, guid: 51af38323954a8d44874780ba4577fb4, type: 3}
|
||||
debugUI: 0
|
||||
playOnStart: 0
|
||||
editor: 1
|
||||
|
@ -6663,7 +6666,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 0, y: 0.5}
|
||||
m_AnchoredPosition: {x: 45, y: 0}
|
||||
m_AnchoredPosition: {x: 42.700012, y: 0}
|
||||
m_SizeDelta: {x: 35, y: 35}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!114 &1665554291
|
||||
|
@ -6903,7 +6906,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 0, y: 0.5}
|
||||
m_AnchoredPosition: {x: 5, y: 0}
|
||||
m_AnchoredPosition: {x: 2.7, y: 0}
|
||||
m_SizeDelta: {x: 35, y: 35}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!114 &1683100750
|
||||
|
|
|
@ -23,6 +23,11 @@ namespace RhythmHeavenMania.Editor
|
|||
[Header("Components")]
|
||||
[SerializeField] private Timeline Timeline;
|
||||
|
||||
[Header("Toolbar")]
|
||||
[SerializeField] private Button NewBTN;
|
||||
[SerializeField] private Button OpenBTN;
|
||||
[SerializeField] private Button SaveBTN;
|
||||
|
||||
public static List<TimelineEventObj> EventObjs = new List<TimelineEventObj>();
|
||||
|
||||
public static Editor instance { get; private set; }
|
||||
|
@ -51,6 +56,10 @@ namespace RhythmHeavenMania.Editor
|
|||
}
|
||||
|
||||
GridGameSelector.GetComponent<GridGameSelector>().SelectGame("Game Manager", 1);
|
||||
|
||||
Tooltip.instance.AddTooltip(NewBTN.gameObject, "New");
|
||||
Tooltip.instance.AddTooltip(OpenBTN.gameObject, "Open");
|
||||
Tooltip.instance.AddTooltip(SaveBTN.gameObject, "Save");
|
||||
}
|
||||
|
||||
public void Update()
|
||||
|
|
|
@ -108,10 +108,10 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
lastBeatPos = Conductor.instance.songPositionInBeats;
|
||||
|
||||
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying)
|
||||
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && CheckIfMouseInTimeline())
|
||||
{
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
|
||||
TimelineSlider.localPosition = new Vector3(Mathp.Round2Nearest(lastMousePos.x + 0.12f, 0.25f), TimelineSlider.transform.localPosition.y);
|
||||
TimelineSlider.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(lastMousePos.x + 0.12f, 0.25f), 0, Mathf.Infinity), TimelineSlider.transform.localPosition.y);
|
||||
|
||||
Conductor.instance.SetBeat(TimelineSlider.transform.localPosition.x);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,9 @@ namespace RhythmHeavenMania.Util
|
|||
AudioSource aus = oneShot.AddComponent<AudioSource>();
|
||||
aus.playOnAwake = false;
|
||||
Sound snd = oneShot.AddComponent<Sound>();
|
||||
snd.clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
AudioClip clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
snd.clip = clip;
|
||||
// snd.pitch = (clip.length / Conductor.instance.secPerBeat);
|
||||
}
|
||||
|
||||
public static void PlayOneShotGame(string name)
|
||||
|
|
|
@ -7,21 +7,48 @@ namespace RhythmHeavenMania.Util
|
|||
public class Sound : MonoBehaviour
|
||||
{
|
||||
public AudioClip clip;
|
||||
public float pitch;
|
||||
public float pitch = 1;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
private int pauseTimes = 0;
|
||||
|
||||
private float startTime;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
audioSource.PlayOneShot(clip);
|
||||
StartCoroutine(play());
|
||||
audioSource.clip = clip;
|
||||
audioSource.pitch = pitch;
|
||||
audioSource.PlayScheduled(Time.time);
|
||||
|
||||
startTime = Conductor.instance.songPosition;
|
||||
}
|
||||
|
||||
private IEnumerator play()
|
||||
private void Update()
|
||||
{
|
||||
if (Conductor.instance.isPaused && !Conductor.instance.isPlaying && pauseTimes == 0)
|
||||
{
|
||||
audioSource.Pause();
|
||||
pauseTimes = 1;
|
||||
print("paused");
|
||||
}
|
||||
else if (Conductor.instance.isPlaying && !Conductor.instance.isPaused && pauseTimes == 1)
|
||||
{
|
||||
audioSource.Play();
|
||||
print("played");
|
||||
pauseTimes = 0;
|
||||
}
|
||||
|
||||
else if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
if (Conductor.instance.songPosition > startTime + clip.length)
|
||||
{
|
||||
yield return new WaitForSeconds(clip.length);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue