pr coments implementation
This commit is contained in:
parent
829de37cd6
commit
2fe84c5c0b
@ -20,7 +20,7 @@ namespace NEG.UI.Popup
|
||||
/// <summary>
|
||||
/// Close popup or mark as closed if not visible
|
||||
/// </summary>
|
||||
/// <param name="silence">if true hide visually, without firing callbacks to properly close</param>
|
||||
void Close(bool silence = false);
|
||||
/// <param name="silent">if true hide visually, without firing callbacks to properly close</param>
|
||||
void Close(bool silent = false);
|
||||
}
|
||||
}
|
||||
15
NEG/UI/UnityUi/Buttons/ButtonReaction.cs
Normal file
15
NEG/UI/UnityUi/Buttons/ButtonReaction.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NEG.UI.UnityUi.Buttons
|
||||
{
|
||||
[RequireComponent(typeof(BaseButton))]
|
||||
public abstract class ButtonReaction : MonoBehaviour
|
||||
{
|
||||
private void Awake() => GetComponent<BaseButton>().OnButtonPressed += OnClicked;
|
||||
|
||||
private void OnDestroy() => GetComponent<BaseButton>().OnButtonPressed -= OnClicked;
|
||||
|
||||
protected abstract void OnClicked();
|
||||
}
|
||||
}
|
||||
3
NEG/UI/UnityUi/Buttons/ButtonReaction.cs.meta
Normal file
3
NEG/UI/UnityUi/Buttons/ButtonReaction.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9761128a04b49c2a26eddfabe70331f
|
||||
timeCreated: 1675707257
|
||||
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -6,16 +7,14 @@ using UnityEngine.SceneManagement;
|
||||
namespace NEG.UI.UnityUi.Buttons
|
||||
{
|
||||
[RequireComponent(typeof(BaseButton))]
|
||||
public class ChangeSceneButton : MonoBehaviour
|
||||
public class ChangeSceneButton : ButtonReaction
|
||||
{
|
||||
[Header("Leave empty to use int value")]
|
||||
[SerializeField] private string sceneName;
|
||||
|
||||
[SerializeField] private int sceneIndex;
|
||||
|
||||
private void Awake() => GetComponent<BaseButton>().OnButtonPressed += OnClicked;
|
||||
|
||||
private void OnClicked()
|
||||
protected override void OnClicked()
|
||||
{
|
||||
if (string.IsNullOrEmpty(sceneName))
|
||||
SceneManager.LoadScene(sceneIndex);
|
||||
|
||||
@ -2,10 +2,8 @@
|
||||
|
||||
namespace NEG.UI.UnityUi.Buttons
|
||||
{
|
||||
[RequireComponent(typeof(BaseButton))]
|
||||
public class CloseAllWindows : MonoBehaviour
|
||||
public class CloseAllWindows : ButtonReaction
|
||||
{
|
||||
private void Awake() => GetComponent<BaseButton>().OnButtonPressed += OnClicked;
|
||||
private void OnClicked() => UiManager.Instance.CurrentArea.CloseAllWindows();
|
||||
protected override void OnClicked() => UiManager.Instance.CurrentArea.CloseAllWindows();
|
||||
}
|
||||
}
|
||||
@ -6,12 +6,11 @@ using UnityEngine;
|
||||
namespace NEG.UI.UnityUi.Buttons
|
||||
{
|
||||
[RequireComponent(typeof(BaseButton))]
|
||||
public class CloseWindow : MonoBehaviour
|
||||
public class CloseWindow : ButtonReaction
|
||||
{
|
||||
[SerializeField] private MonoWindow windowToClose;
|
||||
|
||||
private void Awake() => GetComponent<BaseButton>().OnButtonPressed += OnClicked;
|
||||
private void OnClicked() => windowToClose.Close();
|
||||
|
||||
protected override void OnClicked() => windowToClose.Close();
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
|
||||
@ -8,14 +8,12 @@ using NEG.UI.WindowSlot;
|
||||
namespace NEG.UI.UnityUi.Buttons
|
||||
{
|
||||
[RequireComponent(typeof(BaseButton))]
|
||||
public class OpenWindow : MonoBehaviour
|
||||
public class OpenWindow : ButtonReaction
|
||||
{
|
||||
[SerializeField] private MonoWindow window;
|
||||
[Header("Open on default area slot if empty")]
|
||||
[SerializeField] private MonoWindowSlot slot;
|
||||
|
||||
private void Awake() => GetComponent<BaseButton>().OnButtonPressed += OnClicked;
|
||||
|
||||
private void OnClicked() => window.Open(slot);
|
||||
protected override void OnClicked() => window.Open(slot);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using JetBrains.Annotations;
|
||||
using NEG.UI.UnityUi.Buttons;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@ -83,6 +84,12 @@ namespace NEG.UI.UnityUi
|
||||
prevButton.OnButtonPressed += SelectPrevOption;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
nextButton.OnButtonPressed -= SelectNextOption;
|
||||
prevButton.OnButtonPressed -= SelectPrevOption;
|
||||
}
|
||||
|
||||
private void ChangeOption(bool next) => SelectOption((CurrentOptionId + (next ? 1 : -1) + options.Count) % options.Count);
|
||||
}
|
||||
}
|
||||
@ -16,11 +16,11 @@ namespace NEG.UI.UnityUi.Popup
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Close(bool silence = false)
|
||||
public void Close(bool silent = false)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
|
||||
if(silence)
|
||||
if(silent)
|
||||
return;
|
||||
|
||||
OnPopupClosed?.Invoke(data);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user