diff --git a/AssetsEmbedded/mapinfo b/AssetsEmbedded/mapinfo new file mode 100644 index 0000000..9b1d7c8 Binary files /dev/null and b/AssetsEmbedded/mapinfo differ diff --git a/UnboundLib/Patches/MapLoader.cs b/UnboundLib/Patches/MapLoader.cs index 59f3fe1..afebf55 100644 --- a/UnboundLib/Patches/MapLoader.cs +++ b/UnboundLib/Patches/MapLoader.cs @@ -1,14 +1,29 @@ using HarmonyLib; using UnityEngine; using UnityEngine.SceneManagement; +using TMPro; namespace UnboundLib.Patches { internal class MapLoaderPatch { - [HarmonyPatch(typeof (MapManager), "OnLevelFinishedLoading")] + [HarmonyPatch(typeof(MapManager), "OnLevelFinishedLoading")] private class Patch_OnLevelFinishedLoading { + private static GameObject _mapInfoPrefab; + private static GameObject MapInfoPrefab + { + get + { + if (_mapInfoPrefab == null) + { + _mapInfoPrefab = Unbound.mapInfoAssets.LoadAsset("Map Info Canvas"); + } + return _mapInfoPrefab; + } + } + private static Canvas mapDetailsCanvas; + private static void Prefix(Scene scene, LoadSceneMode mode) { var sfPoly = Resources.FindObjectsOfTypeAll(); @@ -32,6 +47,20 @@ private static void Prefix(Scene scene, LoadSceneMode mode) } } } + + private static void Postfix(Scene scene, LoadSceneMode mode) + { + // disable canvas in last map + if (mapDetailsCanvas) mapDetailsCanvas.gameObject.SetActive(false); + + // create canvas for new map + mapDetailsCanvas = GameObject.Instantiate(MapInfoPrefab).GetComponent(); + SceneManager.MoveGameObjectToScene(mapDetailsCanvas.gameObject, scene); + + // set level text + var mapName = MapManager.instance.levels[MapManager.instance.currentLevelID]; + mapDetailsCanvas.GetComponentInChildren().text = mapName; + } } } } \ No newline at end of file diff --git a/UnboundLib/Unbound.cs b/UnboundLib/Unbound.cs index a491acc..89be587 100644 --- a/UnboundLib/Unbound.cs +++ b/UnboundLib/Unbound.cs @@ -25,7 +25,7 @@ public class Unbound : BaseUnityPlugin { private const string ModId = "com.willis.rounds.unbound"; private const string ModName = "Rounds Unbound"; - public const string Version = "3.2.7"; + public const string Version = "3.2.8"; public static Unbound Instance { get; private set; } public static readonly ConfigFile config = new ConfigFile(Path.Combine(Paths.ConfigPath, "UnboundLib.cfg"), true); @@ -74,9 +74,11 @@ public const string public static readonly Dictionary lockInputBools = new Dictionary(); - internal static AssetBundle UIAssets; public static AssetBundle toggleUI; + internal static AssetBundle UIAssets; internal static AssetBundle linkAssets; + internal static AssetBundle mapInfoAssets; + private static GameObject modalPrefab; private TextMeshProUGUI text; @@ -371,6 +373,7 @@ private static void LoadAssets() modalPrefab = UIAssets.LoadAsset("Modal"); //Instantiate(UIAssets.LoadAsset("Card Toggle Menu"), canvas.transform).AddComponent(); } + mapInfoAssets = AssetUtils.LoadAssetBundleFromResources("mapinfo", typeof(Unbound).Assembly); } private static void OnJoinedRoomAction() diff --git a/UnboundLib/UnboundLib.csproj b/UnboundLib/UnboundLib.csproj index 099ac14..6bc8969 100644 --- a/UnboundLib/UnboundLib.csproj +++ b/UnboundLib/UnboundLib.csproj @@ -46,6 +46,7 @@ +