using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TestCubeSpawner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestCubeSpawner")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("621c7191-a219-4b93-b385-a4cfdf3cb3ab")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.ivan.ultrakill.fbxspawner", "FBX Spawner GUI", "1.0.1")]
public class FBXSpawnerGUI : BaseUnityPlugin
{
[HarmonyPatch(typeof(NewMovement), "Update")]
private class PatchInput
{
private static void Postfix()
{
if (Input.GetKeyDown((KeyCode)282))
{
showGUI = !showGUI;
log.LogInfo((object)("Menu " + (showGUI ? "opened" : "closed")));
if (showGUI)
{
CreateCanvas();
}
else
{
DestroyCanvas();
}
}
if (showGUI && Input.GetKeyDown((KeyCode)27))
{
showGUI = false;
DestroyCanvas();
log.LogInfo((object)"Menu closed (ESC)");
}
}
}
internal static ManualLogSource log;
internal static bool showGUI = false;
internal static List<string> modelFiles = new List<string>();
internal static GameObject spawnedObject;
internal static GameObject canvasObject;
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
log = ((BaseUnityPlugin)this).Logger;
log.LogInfo((object)"FBX Spawner GUI loaded! Press F1 to toggle menu.");
Harmony val = new Harmony("com.ivan.ultrakill.fbxspawner");
val.PatchAll();
ScanModels();
}
internal static void ScanModels()
{
try
{
modelFiles.Clear();
string directoryName = Path.GetDirectoryName(typeof(FBXSpawnerGUI).Assembly.Location);
if (string.IsNullOrEmpty(directoryName))
{
return;
}
string path = Path.Combine(directoryName, "Models");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
log.LogWarning((object)"Created Models folder. Place your .fbx files there!");
return;
}
string[] files = Directory.GetFiles(path, "*.fbx");
modelFiles.AddRange(files.Select(Path.GetFileName));
log.LogInfo((object)$"Found {modelFiles.Count} .fbx files");
foreach (string modelFile in modelFiles)
{
log.LogInfo((object)(" • " + modelFile));
}
}
catch (Exception ex)
{
log.LogError((object)("Error scanning Models folder: " + ex.Message));
}
}
internal static void CreateCanvas()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Expected O, but got Unknown
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Expected O, but got Unknown
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Expected O, but got Unknown
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0376: Unknown result type (might be due to invalid IL or missing references)
//IL_038d: Unknown result type (might be due to invalid IL or missing references)
//IL_039a: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0463: Unknown result type (might be due to invalid IL or missing references)
//IL_0470: Unknown result type (might be due to invalid IL or missing references)
//IL_047a: Expected O, but got Unknown
if ((Object)(object)canvasObject != (Object)null)
{
return;
}
canvasObject = new GameObject("FBXCanvas");
Object.DontDestroyOnLoad((Object)(object)canvasObject);
Canvas val = canvasObject.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 10000;
canvasObject.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)1;
canvasObject.AddComponent<GraphicRaycaster>();
if ((Object)(object)Object.FindObjectOfType<EventSystem>() == (Object)null)
{
GameObject val2 = new GameObject("EventSystem");
val2.AddComponent<EventSystem>();
val2.AddComponent<StandaloneInputModule>();
Object.DontDestroyOnLoad((Object)(object)val2);
}
GameObject val3 = new GameObject("Panel");
val3.transform.SetParent(canvasObject.transform, false);
RectTransform val4 = val3.AddComponent<RectTransform>();
val4.anchorMin = new Vector2(0.5f, 0.5f);
val4.anchorMax = new Vector2(0.5f, 0.5f);
val4.sizeDelta = new Vector2(220f, 260f);
val4.anchoredPosition = Vector2.zero;
Image val5 = val3.AddComponent<Image>();
((Graphic)val5).color = new Color(0.08f, 0.08f, 0.12f, 0.95f);
CreateText(val3.transform, "FBX SPAWNER", 16, Color.yellow, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -8f));
CreateText(val3.transform, "F1 - toggle • ESC - close", 10, new Color(0.85f, 0.85f, 0.9f), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -28f));
GameObject val6 = new GameObject("Scroll");
val6.transform.SetParent(val3.transform, false);
ScrollRect val7 = val6.AddComponent<ScrollRect>();
val7.horizontal = false;
RectTransform component = val6.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0f, 0f);
component.anchorMax = new Vector2(1f, 1f);
component.offsetMin = new Vector2(10f, 10f);
component.offsetMax = new Vector2(-10f, -40f);
GameObject val8 = new GameObject("Scrollbar");
val8.transform.SetParent(val6.transform, false);
Scrollbar val9 = val8.AddComponent<Scrollbar>();
val9.direction = (Direction)2;
((Selectable)val9).transition = (Transition)1;
RectTransform component2 = val8.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(1f, 0f);
component2.anchorMax = new Vector2(1f, 1f);
component2.pivot = new Vector2(1f, 1f);
component2.sizeDelta = new Vector2(12f, 0f);
component2.anchoredPosition = Vector2.zero;
val7.verticalScrollbar = val9;
GameObject val10 = new GameObject("Content");
val10.transform.SetParent(val6.transform, false);
RectTransform val11 = val10.AddComponent<RectTransform>();
val11.anchorMin = new Vector2(0f, 1f);
val11.anchorMax = new Vector2(1f, 1f);
val11.pivot = new Vector2(0.5f, 1f);
val11.anchoredPosition = Vector2.zero;
val7.content = val11;
VerticalLayoutGroup val12 = val10.AddComponent<VerticalLayoutGroup>();
((LayoutGroup)val12).padding = new RectOffset(8, 8, 8, 8);
((HorizontalOrVerticalLayoutGroup)val12).spacing = 3f;
((HorizontalOrVerticalLayoutGroup)val12).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)val12).childForceExpandWidth = false;
((LayoutGroup)val12).childAlignment = (TextAnchor)1;
val10.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
if (modelFiles.Count > 0)
{
foreach (string file in modelFiles)
{
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
CreateButton(val10.transform, fileNameWithoutExtension, 12, new Color(0.5f, 1f, 0.5f), (UnityAction)delegate
{
SpawnModel(file);
});
}
return;
}
CreateText(val10.transform, "No .fbx files found", 12, Color.red, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f));
}
private static void CreateText(Transform parent, string text, int fontSize, Color color, Vector2 anchorMin = default(Vector2), Vector2 anchorMax = default(Vector2), Vector2 anchoredPos = default(Vector2))
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Text");
val.transform.SetParent(parent, false);
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).text = text;
((TMP_Text)val2).fontSize = fontSize;
((Graphic)val2).color = color;
((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
((TMP_Text)val2).fontStyle = (FontStyles)1;
((TMP_Text)val2).enableAutoSizing = false;
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = (Vector2)((anchorMin == default(Vector2)) ? new Vector2(0f, 1f) : anchorMin);
component.anchorMax = (Vector2)((anchorMax == default(Vector2)) ? new Vector2(1f, 1f) : anchorMax);
component.pivot = new Vector2(0.5f, 1f);
component.anchoredPosition = anchoredPos;
}
private static void CreateButton(Transform parent, string text, int fontSize, Color textColor, UnityAction onClick)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Button");
val.transform.SetParent(parent, false);
Image val2 = val.AddComponent<Image>();
((Graphic)val2).color = new Color(0.16f, 0.16f, 0.2f, 1f);
Button val3 = val.AddComponent<Button>();
((Selectable)val3).targetGraphic = (Graphic)(object)val2;
((UnityEvent)val3.onClick).AddListener(onClick);
ColorBlock colors = ((Selectable)val3).colors;
((ColorBlock)(ref colors)).highlightedColor = new Color(0.26f, 0.26f, 0.32f);
((ColorBlock)(ref colors)).pressedColor = new Color(0.1f, 0.1f, 0.14f);
((Selectable)val3).colors = colors;
LayoutElement val4 = val.AddComponent<LayoutElement>();
val4.preferredHeight = 20f;
val4.minHeight = 20f;
val4.preferredWidth = 180f;
val4.minWidth = 180f;
GameObject val5 = new GameObject("Text");
val5.transform.SetParent(val.transform, false);
TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
((TMP_Text)val6).text = text;
((TMP_Text)val6).fontSize = fontSize;
((Graphic)val6).color = textColor;
((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
((TMP_Text)val6).enableAutoSizing = false;
RectTransform component = ((Component)val6).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = new Vector2(4f, 2f);
component.offsetMax = new Vector2(-4f, -2f);
}
private static void SpawnModel(string fileName)
{
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
log.LogInfo((object)("Spawning placeholder for " + fileName));
if ((Object)(object)spawnedObject != (Object)null)
{
Object.Destroy((Object)(object)spawnedObject);
}
GameObject val = GameObject.FindWithTag("Player");
if ((Object)(object)val == (Object)null)
{
log.LogError((object)"Player not found!");
return;
}
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)val2).name = Path.GetFileNameWithoutExtension(fileName) + " (FBX)";
val2.tag = "Environment";
val2.layer = LayerMask.NameToLayer("Environment");
val2.transform.localScale = Vector3.one * 5f;
val2.GetComponent<Renderer>().material.color = Color.yellow;
Vector3 position = val.transform.position + val.transform.forward * 30f + Vector3.up * 10f;
val2.transform.position = position;
spawnedObject = val2;
log.LogInfo((object)("Spawned: " + ((Object)val2).name + " (placeholder)"));
}
internal static void DestroyCanvas()
{
if ((Object)(object)canvasObject != (Object)null)
{
Object.Destroy((Object)(object)canvasObject);
canvasObject = null;
}
}
}