2020-12-24 15:57:25 +00:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using OWML.Utils;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Utility
|
|
|
|
|
{
|
|
|
|
|
public static class DebugBoxManager
|
|
|
|
|
{
|
|
|
|
|
private static GameObject _boxPrefab;
|
|
|
|
|
|
|
|
|
|
public static void Init()
|
|
|
|
|
{
|
|
|
|
|
_boxPrefab = QSBCore.ConversationAssetBundle.LoadAsset<GameObject>("assets/dialoguebubble.prefab");
|
|
|
|
|
var font = (Font)Resources.Load(@"fonts\english - latin\spacemono-bold");
|
|
|
|
|
if (font == null)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole("Error - Font is null!", MessageType.Error);
|
|
|
|
|
}
|
|
|
|
|
_boxPrefab.GetComponent<Text>().font = font;
|
|
|
|
|
_boxPrefab.GetComponent<Text>().color = Color.white;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static GameObject CreateBox(Transform parent, float vertOffset, string text)
|
|
|
|
|
{
|
2020-12-24 16:34:24 +00:00
|
|
|
|
var newBox = Object.Instantiate(_boxPrefab);
|
2020-12-24 15:57:25 +00:00
|
|
|
|
newBox.SetActive(false);
|
2020-12-31 12:10:55 +00:00
|
|
|
|
newBox.transform.SetParent(parent);
|
2020-12-24 15:57:25 +00:00
|
|
|
|
newBox.transform.localPosition = new Vector3(0, vertOffset, 0);
|
|
|
|
|
newBox.transform.rotation = parent.rotation;
|
|
|
|
|
var lookAt = newBox.AddComponent<FaceActiveCamera>();
|
|
|
|
|
lookAt.SetValue("_useLookAt", false);
|
|
|
|
|
lookAt.SetValue("_localFacingVector", Vector3.back);
|
|
|
|
|
lookAt.SetValue("_localRotationAxis", Vector3.up);
|
|
|
|
|
newBox.GetComponent<Text>().text = text;
|
|
|
|
|
newBox.AddComponent<DebugZOverride>();
|
|
|
|
|
newBox.SetActive(true);
|
|
|
|
|
return newBox;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-10 20:37:42 +00:00
|
|
|
|
}
|