Aetheria/Assets/Scripts/UI/ConfirmationDialog.cs
Reinier Vens 4f19189244 Menu Screen + UI Restyle
Created menu screen
Created inventory tab with 2 cargo panes and properties panel
Updated the style of every UI prefab
Implemented Blurred UI material
Implemented UI shaders for map layers
Created Map tab (still needs input)
2020-12-14 02:56:35 +00:00

55 lines
1.3 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ConfirmationDialog : PropertiesPanel
{
public ClickCatcher CancelClickCatcher;
public Button Cancel;
public Button Confirm;
private Action _onCancel;
private Action _onConfirm;
private new void Start()
{
Cancel.onClick.AddListener(() =>
{
_onCancel?.Invoke();
End();
});
Confirm.onClick.AddListener(() =>
{
_onConfirm?.Invoke();
End();
});
if (CancelClickCatcher != null)
CancelClickCatcher.OnClick += data =>
{
_onCancel?.Invoke();
End();
};
OnPropertyAdded += go =>
{
go.SetActive(true);
go.transform.SetSiblingIndex(Title.transform.GetSiblingIndex() + 1);
};
}
private void End()
{
CancelClickCatcher.gameObject.SetActive(false);
gameObject.SetActive(false);
}
public void Show(Action onConfirm, Action onCancel = null)
{
_onConfirm = onConfirm;
_onCancel = onCancel;
transform.position = Input.mousePosition;
CancelClickCatcher.gameObject.SetActive(true);
}
}