|
|
@ -20,14 +20,14 @@ namespace Fungus |
|
|
|
// Currently active Menu Dialog used to display Menu options |
|
|
|
// Currently active Menu Dialog used to display Menu options |
|
|
|
public static MenuDialog activeMenuDialog; |
|
|
|
public static MenuDialog activeMenuDialog; |
|
|
|
|
|
|
|
|
|
|
|
[Tooltip("Automatically select the first interactable button when the menu is shown.")] |
|
|
|
[Tooltip("Automatically select the first interactable button when the menu is shown.")] |
|
|
|
public bool autoSelectFirstButton = false; |
|
|
|
public bool autoSelectFirstButton = false; |
|
|
|
|
|
|
|
|
|
|
|
[NonSerialized] |
|
|
|
[NonSerialized] |
|
|
|
public Button[] cachedButtons; |
|
|
|
public Button[] cachedButtons; |
|
|
|
|
|
|
|
|
|
|
|
[NonSerialized] |
|
|
|
[NonSerialized] |
|
|
|
public Slider cachedSlider; |
|
|
|
public Slider cachedSlider; |
|
|
|
|
|
|
|
|
|
|
|
public static MenuDialog GetMenuDialog() |
|
|
|
public static MenuDialog GetMenuDialog() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -73,10 +73,10 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual void OnEnable() |
|
|
|
public virtual void OnEnable() |
|
|
|
{ |
|
|
|
{ |
|
|
|
// The canvas may fail to update if the menu dialog is enabled in the first game frame. |
|
|
|
// The canvas may fail to update if the menu dialog is enabled in the first game frame. |
|
|
|
// To fix this we just need to force a canvas update when the object is enabled. |
|
|
|
// To fix this we just need to force a canvas update when the object is enabled. |
|
|
|
Canvas.ForceUpdateCanvases(); |
|
|
|
Canvas.ForceUpdateCanvases(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual void Clear() |
|
|
|
public virtual void Clear() |
|
|
@ -115,10 +115,10 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
button.interactable = interactable; |
|
|
|
button.interactable = interactable; |
|
|
|
|
|
|
|
|
|
|
|
if (interactable && autoSelectFirstButton && !cachedButtons.Select((x) => x.gameObject).Contains(EventSystem.current.currentSelectedGameObject)) |
|
|
|
if (interactable && autoSelectFirstButton && !cachedButtons.Select((x) => x.gameObject).Contains(EventSystem.current.currentSelectedGameObject)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
EventSystem.current.SetSelectedGameObject(button.gameObject); |
|
|
|
EventSystem.current.SetSelectedGameObject(button.gameObject); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Text textComponent = button.GetComponentInChildren<Text>(); |
|
|
|
Text textComponent = button.GetComponentInChildren<Text>(); |
|
|
|
if (textComponent != null) |
|
|
|
if (textComponent != null) |
|
|
@ -130,7 +130,7 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
button.onClick.AddListener(delegate { |
|
|
|
button.onClick.AddListener(delegate { |
|
|
|
|
|
|
|
|
|
|
|
EventSystem.current.SetSelectedGameObject(null); |
|
|
|
EventSystem.current.SetSelectedGameObject(null); |
|
|
|
|
|
|
|
|
|
|
|
StopAllCoroutines(); // Stop timeout |
|
|
|
StopAllCoroutines(); // Stop timeout |
|
|
|
Clear(); |
|
|
|
Clear(); |
|
|
@ -173,7 +173,7 @@ namespace Fungus |
|
|
|
if (cachedSlider != null) |
|
|
|
if (cachedSlider != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
cachedSlider.gameObject.SetActive(true); |
|
|
|
cachedSlider.gameObject.SetActive(true); |
|
|
|
gameObject.SetActive(true); |
|
|
|
gameObject.SetActive(true); |
|
|
|
StopAllCoroutines(); |
|
|
|
StopAllCoroutines(); |
|
|
|
StartCoroutine(WaitForTimeout(duration, targetBlock)); |
|
|
|
StartCoroutine(WaitForTimeout(duration, targetBlock)); |
|
|
|
} |
|
|
|
} |
|
|
|