Files
K-C-Multiplayer/PrefabManager.cs
2025-12-14 21:38:38 +01:00

66 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace KCM
{
public class PrefabManager
{
public static AssetBundle assetBundle;
public static GameObject serverBrowserPrefab;
public static GameObject serverEntryItemPrefab;
public static GameObject serverLobbyPrefab;
public static GameObject serverLobbyPlayerEntryPrefab;
public static GameObject serverChatEntryPrefab;
public static GameObject serverChatSystemEntryPrefab;
public static GameObject modalUIPrefab;
public static void PreScriptLoad(KCModHelper _helper)
{
helper = _helper;
if (helper == null)
{
helper = Main.instance.helper;
}
var assetBundle = helper.LoadAssetBundle(helper.modPath, "serverbrowserpkg");
if (assetBundle == null)
{
Main.helper.Log("ERROR: Asset bundle 'serverbrowserpkg' not found! UI features will not work.");
Main.helper.Log("Please ensure the asset bundle file is in the mod directory.");
return;
}
Main.helper.Log("Asset bundle loaded successfully");
Main.helper.Log("Assets in bundle: " + String.Join(", ", assetBundle.GetAllAssetNames()));
serverBrowserPrefab = assetBundle.LoadAsset("assets/workspace/serverbrowser.prefab") as GameObject;
serverEntryItemPrefab = assetBundle.LoadAsset("assets/workspace/serverentryitem.prefab") as GameObject;
serverLobbyPrefab = assetBundle.LoadAsset("assets/workspace/serverlobby.prefab") as GameObject;
serverLobbyPlayerEntryPrefab = assetBundle.LoadAsset("assets/workspace/serverlobbyplayerentry.prefab") as GameObject;
serverChatEntryPrefab = assetBundle.LoadAsset("assets/workspace/serverchatentry.prefab") as GameObject;
serverChatSystemEntryPrefab = assetBundle.LoadAsset("assets/workspace/serverchatsystementry.prefab") as GameObject;
modalUIPrefab = assetBundle.LoadAsset("assets/workspace/modalui.prefab") as GameObject;
Main.helper.Log("Loaded all UI prefabs successfully");
}
catch (Exception ex)
{
Main.helper.Log("ERROR loading asset bundle:");
Main.helper.Log(ex.ToString());
Main.helper.Log(ex.Message);
Main.helper.Log(ex.StackTrace);
}
}
}
}