This repository was archived by the owner on May 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
41 lines (37 loc) · 1.41 KB
/
Copy pathMain.cs
File metadata and controls
41 lines (37 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Assets.Scripts.Database;
using HarmonyLib;
using MelonLoader;
using UnityEngine;
using UnityEngine.UI;
namespace BPMDisplay
{
public class Main : MelonMod
{
}
[HarmonyPatch(typeof(PnlPreparation))]
internal static class PnlPreparationPatch
{
private static GameObject BpmGameObject { get; set; }
[HarmonyPostfix]
[HarmonyPatch("Awake")]
internal static void AwakePostfix()
{
var txtStageDesigner = GameObject.Find("TxtStageDesigner");
var levelDesignerTransform = txtStageDesigner.transform.GetChild(0);
var position = levelDesignerTransform.position;
BpmGameObject = Object.Instantiate(levelDesignerTransform.gameObject, txtStageDesigner.transform);
BpmGameObject.name = "BPM";
BpmGameObject.GetComponent<RectTransform>().position = new Vector3(position.x, position.y + 0.9f, position.z);
}
[HarmonyPostfix]
[HarmonyPatch("OnEnable")]
internal static void OnEnablePostfix()
{
var musicInfo = GlobalDataBase.s_DbMusicTag.m_CurSelectedMusicInfo.bpm != null
? GlobalDataBase.s_DbMusicTag.m_CurSelectedMusicInfo
: GlobalDataBase.s_DbMusicTag.m_CurRandomMusicInfo;
var bpm = musicInfo.bpm;
BpmGameObject.transform.GetChild(0).GetComponent<Text>().text = "BPM: " + bpm;
}
}
}