Skip to content

Instantly share code, notes, and snippets.

View nomnomab's full-sized avatar
🛠️
Making mods and Project Ictos

Andrew Burke nomnomab

🛠️
Making mods and Project Ictos
View GitHub Profile
#if UNITY_EDITOR
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
@nomnomab
nomnomab / FullBrightSceneCamera.cs
Last active May 27, 2024 23:53
Lets you view a scene with even lighting.
using UnityEditor;
using UnityEngine;
namespace Nomnom.Editor {
public sealed class FullBrightSceneCamera {
private const string KEY = "key_FullBrightSceneCamera";
private static Transform? _rig = null;
[InitializeOnLoadMethod]
@nomnomab
nomnomab / LoremIpsumExtension.cs
Created May 4, 2024 15:06
Adds a context option to text types to quickly add some test sentences.
using TMPro;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
internal static class LoremIpsumExtension {
private const string LOREM_IPSUM_SHORT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
private const string LOREM_IPSUM_MEDIUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam gravida orci in efficitur vulputate. Nunc quis nunc hendrerit, egestas libero non, ullamcorper enim.";
private const string LOREM_IPSUM_LONG = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam gravida orci in efficitur vulputate. Nunc quis nunc hendrerit, egestas libero non, ullamcorper enim. Praesent accumsan auctor orci, sed pharetra nulla efficitur at. Vivamus lacus arcu, malesuada eget magna vitae, condimentum maximus mauris.";
private const string LOREM_IPSUM_EXTRA_LONG = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam gravida orci in efficitur vulputate. Nunc quis nunc hendrerit, egestas libero non, ullamcorper enim. Praesent accumsan auctor orc
@nomnomab
nomnomab / Plugin.cs
Created January 9, 2024 16:50
Adds an unlit mode to Lethal Company's cameras
// it didn't add the object properly in Awake, so I put it in OnDestroy instead
// as the plugin object is destroyed when loading is done
private void OnDestroy() {
var unlitHandler = new GameObject("UnlitModeHandler").AddComponent<UnlitModeHandler>();
DontDestroyOnLoad(unlitHandler);
}
@nomnomab
nomnomab / AddCustomEnemy.cs
Created January 1, 2024 16:19
Adding a custom enemy to the dev dropdown for Lethal Company
[HarmonyPatch(typeof(QuickMenuManager), "Debug_SetEnemyDropdownOptions")]
[HarmonyPrefix]
private static void AddGiantToDebugList(QuickMenuManager __instance) {
// ? isn't in the main level list so have to add here
// ? adding in Start didn't seem to work
var testLevel = __instance.testAllEnemiesLevel;
var firstEnemy = testLevel.Enemies.FirstOrDefault();
if (firstEnemy == null) {
Plugin.Log.LogError("Failed to get first enemy for debug list!");
return;
@nomnomab
nomnomab / SimplifyEnum.cs
Created May 3, 2023 16:50
Unity editor enum compression for invalid states
private static class EnumCache<T> where T : Enum {
public static T[] Values { get; } = (T[])Enum.GetValues(typeof(T));
}
// 32-bit max enum simplification
private static int SimplifyEnum<T>(T e) where T: Enum {
var values = EnumCache<T>.Values;
var max = 0;
var number = Convert.ToInt32(e);
@nomnomab
nomnomab / PercentageFill.cs
Last active October 31, 2022 19:28
A visual representation of two fill objects in a single container.
using System;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[ExecuteAlways]
[DisallowMultipleComponent]
[RequireComponent(typeof(RectTransform))]
public class PercentageFill : LayoutGroup {
@nomnomab
nomnomab / SimpleTitleAttribute.cs
Last active March 28, 2022 15:54
A custom title that is better than Unity's
using UnityEngine;
namespace SLController.Attributes {
public class SimpleTitleAttribute: PropertyAttribute {
public readonly string Text;
public readonly string Style;
public SimpleTitleAttribute(string text, string style = null) {
Text = text;
Style = style;
@nomnomab
nomnomab / MaxLengthAttribute.cs
Created February 2, 2022 23:17
Constrains a string field's length
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class MaxLengthAttribute : PropertyAttribute {
public readonly uint Length;
public MaxLengthAttribute(uint length) {
@nomnomab
nomnomab / RandomNumberInRange.cs
Last active June 21, 2021 20:30
Random number in a range whilst excluding an inner range
public static int RandomNumberInRange(int min, int max, int minExclusion, int maxExclusion) {
int value = Random.Range(min, max + 1 - maxExclusion + minExclusion);
value += value >= minExclusion ? maxExclusion - minExclusion : 0;
return value;
}