Skip to content

Commit

Permalink
#764 addresses FIXME: pause and play sprite now load once
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahAugustinowski authored and falko17 committed Sep 1, 2024
1 parent 4a7d034 commit eab7f1d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions Assets/SEE/UI/HelpSystem/HelpSystemEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,27 +381,42 @@ public void Back()
Destroyer.Destroy(helpSystemSpace);
}

private Sprite playIcon;
private Sprite pauseIcon;

/// <summary>
/// Initializes the sprites to avoid loading them multiple times.
/// </summary>
private void InitializeIcons()
{
playIcon = Resources.Load<Sprite>("Materials/40+ Simple Icons - Free/RewindOneFrameForward_Simple_Icons_UI");
pauseIcon = Resources.Load<Sprite>("Materials/40+ Simple Icons - Free/Pause_Simple_Icons_UI");
}

/// <summary>
/// Toggles the "IsPlaying" state. If the entry is running, it will be paused; if it is paused,
/// it will be played on.
/// </summary>
public void TogglePlaying()
{
if (playIcon == null || pauseIcon == null)
{
InitializeIcons();
}

helpSystemEntry.transform.Find("Content/Lower Video/Buttons/Pause")
.gameObject.TryGetComponentOrLog(out pauseButton);
if (!IsPlaying)
{
// FIXME: Should this resource really be loaded each time playing is toggled?
pauseButton.buttonIcon = Resources.Load<Sprite>("Materials/40+ Simple Icons - Free/Pause_Simple_Icons_UI");
pauseButton.buttonIcon = pauseIcon;
pauseButton.UpdateUI();
videoPlayer.Play();
Speaker.Instance.PauseOrUnPause();
IsPlaying = true;
}
else
{
// FIXME: Should this resource really be loaded each time playing is toggled?
pauseButton.buttonIcon = Resources.Load<Sprite>("Materials/40+ Simple Icons - Free/RewindOneFrameForward_Simple_Icons_UI");
pauseButton.buttonIcon = playIcon;
pauseButton.UpdateUI();
videoPlayer.Pause();
Speaker.Instance.Pause();
Expand Down

0 comments on commit eab7f1d

Please sign in to comment.