Skip to content

Commit

Permalink
add SetButtonVisible
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Mar 22, 2024
1 parent 4f5c977 commit d96a04d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/OWML.Utils/MenuExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
namespace OWML.Utils
using UnityEngine;

namespace OWML.Utils
{
public static class MenuExtensions
{
public static void SetMessage(this PopupMenu menu, string message) => menu._labelText.text = message;

public static void SetButtonVisible(this SubmitAction buttonAction, bool visible)
{
var activeAlpha = 1;

if (LoadManager.GetCurrentScene() == OWScene.TitleScreen)
{
var titleAnimationController = Resources.FindObjectsOfTypeAll<TitleScreenManager>()[0]._gfxController;
activeAlpha = titleAnimationController.IsTitleAnimationComplete() ? 1 : 0;
if (titleAnimationController.IsFadingInMenuOptions())
{
activeAlpha = 1;
}
}

buttonAction.gameObject.SetActive(visible);
buttonAction.GetComponent<CanvasGroup>().alpha = visible ? activeAlpha : 0;
}
}
}

0 comments on commit d96a04d

Please sign in to comment.