2022-08-27 03:43:01 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Editor.Track;
|
|
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
2023-12-26 05:22:51 +00:00
|
|
|
namespace HeavenStudio.Editor
|
2022-08-27 03:43:01 +00:00
|
|
|
{
|
|
|
|
public class Dialog : MonoBehaviour
|
|
|
|
{
|
2024-05-08 19:26:43 +00:00
|
|
|
public bool IsOpen => dialog.activeSelf;
|
|
|
|
[SerializeField] internal RectTransform rectTransform;
|
2022-08-27 03:43:01 +00:00
|
|
|
[SerializeField] protected GameObject dialog;
|
|
|
|
public void ForceState(bool onoff = false)
|
|
|
|
{
|
2023-05-07 20:33:15 +00:00
|
|
|
dialog.SetActive(onoff);
|
|
|
|
if (Editor.instance == null) return;
|
2022-10-13 16:20:48 +00:00
|
|
|
Editor.instance.canSelect = !onoff;
|
|
|
|
Editor.instance.inAuthorativeMenu = onoff;
|
2022-08-27 03:43:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void ResetAllDialogs()
|
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
foreach (var dialog in FindObjectsOfType<Dialog>())
|
2022-08-27 03:43:01 +00:00
|
|
|
{
|
|
|
|
dialog.ForceState(false);
|
|
|
|
}
|
|
|
|
}
|
2024-05-08 19:26:43 +00:00
|
|
|
|
|
|
|
public void SwitchDialogue()
|
|
|
|
{
|
|
|
|
if (dialog.activeSelf) {
|
|
|
|
dialog.SetActive(false);
|
|
|
|
} else {
|
|
|
|
ResetAllDialogs();
|
|
|
|
dialog.SetActive(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetPosRelativeToButtonPos(RectTransform buttonRect, Vector2? relativePos = null)
|
|
|
|
{
|
|
|
|
// janky? maybe. does it work? you bet it does
|
|
|
|
rectTransform.SetParent(buttonRect);
|
|
|
|
rectTransform.localPosition = relativePos ?? new Vector2(210, 120);
|
|
|
|
// rectTransform.localPosition = new Vector2((rectTransform.rect.width - buttonRect.rect.width) / 2, (rectTransform.rect.height + buttonRect.rect.height) / 2);
|
|
|
|
// rectTransform.offsetMin = Vector2.up * (buttonRect.rect.height + 7);
|
|
|
|
|
|
|
|
rectTransform.SetParent(Editor.instance.MainCanvas.transform, true);
|
|
|
|
}
|
2022-08-27 03:43:01 +00:00
|
|
|
}
|
|
|
|
}
|