add modal window UI

This commit is contained in:
Vladimir Koshevarov
2022-12-06 11:25:30 +02:00
parent 3ccfc6a353
commit 71d9f79442
12 changed files with 2138 additions and 49 deletions
@@ -0,0 +1,61 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ModalWindowPanel : MonoBehaviour
{
[Header("Header")]
[SerializeField]
private Transform _hederArea;
[SerializeField]
private Transform _titleField;
[Header("Content")]
[SerializeField]
private Transform _contentArea;
[SerializeField]
private Transform _verticalLayoutArea;
[SerializeField]
private Image _heroImage;
[SerializeField]
private TextMeshProUGUI _heroText;
[Space()]
[SerializeField]
private Transform _horizontalLayoutArea;
[SerializeField]
private Image _iconImage;
[SerializeField]
private TextMeshProUGUI _iconText;
[Header("Footer")]
[SerializeField]
private Transform _footerArea;
[SerializeField]
private Button _confirmButton;
[SerializeField]
private Button _declineButton;
private Action onConfirmAction;
private Action onDeclineAction;
public void Confirm()
{
onConfirmAction?.Invoke();
// Close();
}
public void Decline()
{
onDeclineAction?.Invoke();
//Close();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1c8cd26649ff30a4ea72d44d9bcd0edf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+56
View File
@@ -0,0 +1,56 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[ExecuteInEditMode()]
public class ToolTip : MonoBehaviour
{
public TextMeshProUGUI headerField;
public TextMeshProUGUI contentField;
public LayoutElement layoutElement;
public int characterWrapLimit;
public RectTransform rectTransform;
private void Awake()
{
rectTransform = GetComponent<RectTransform>();
}
// Start is called before the first frame update
public void SetText(string content, string header = "")
{
if (string.IsNullOrEmpty(header))
{
headerField.gameObject.SetActive(false);
}
else
{
headerField.gameObject.SetActive(true);
headerField.text = header;
}
contentField.text = content;
int headerLength = headerField.text.Length;
int contentLength = contentField.text.Length;
layoutElement.enabled = (headerLength > characterWrapLimit || contentLength > characterWrapLimit);
}
// Update is called once per frame
void Update()
{
if (Application.isEditor)
{
int headerLength = headerField.text.Length;
int contentLength = contentField.text.Length;
layoutElement.enabled = (headerLength > characterWrapLimit || contentLength > characterWrapLimit);
}
Vector2 position = Input.mousePosition;
float pivotX = position.x / Screen.width;
float pivotY = position.y / Screen.height;
rectTransform.pivot = new Vector2(pivotX, pivotY);
transform.position = position;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: feff04ad815f5974cb387c4ae348a844
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
using UnityEngine;
public class ToolTipSystem : MonoBehaviour
{
private static ToolTipSystem _current;
[SerializeField] private ToolTip _toolTip;
public void Awake()
{
_current = this;
_current._toolTip.gameObject.SetActive(false);
}
public static void Show(string content, string header = "")
{
_current._toolTip.SetText(content, header);
_current._toolTip.gameObject.SetActive(true);
}
public static void Hide()
{
_current._toolTip.gameObject.SetActive(false);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 49f5114aac344be42a48ac8ceb3b93fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,23 @@
using UnityEngine;
using UnityEngine.EventSystems;
public class ToolTipTrigger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
private static LTDescr delay;
[SerializeField] private string _content;
[SerializeField] private string _header;
public void OnPointerEnter(PointerEventData eventData)
{
delay = LeanTween.delayedCall(0.5f, () =>
{
ToolTipSystem.Show(_content, _header);
});
}
public void OnPointerExit(PointerEventData eventData)
{
LeanTween.cancel(delay.uniqueId);
ToolTipSystem.Hide();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b31294925f6cbdb40969c856428d8894
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: