Skip to content

Instantly share code, notes, and snippets.

@Monsoonexe
Monsoonexe / WindowDragHandle.cs
Last active March 5, 2024 15:32
Drag component for windows in Unity
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace SmolderSoft.Gists
{
/// <summary>
/// Add this component to a Graphic to allow dragging. Keeps within the bounds of the screen.
/// </summary>
public class DraggableWindow : MonoBehaviour, IDragHandler, IBeginDragHandler
@Monsoonexe
Monsoonexe / CompilerLockMenuItem.cs
Last active October 18, 2023 23:21
Tool for Unity Editor to un/lock unity's compiler, preventing it from compiling when it is inconvenient
private const string CompilerLockMenu = "Tools/Lock Compiler";
[MenuItem(CompilerLockMenu)]
public static void ToggleCompilerLock()
{
// get current state
bool locked = Menu.GetChecked(CompilerLockMenu);
// flip
Menu.SetChecked(CompilerLockMenu, !locked);
@Monsoonexe
Monsoonexe / PlayerController.cs
Created April 20, 2023 14:17
PlayerController
using UnityEngine;
using UnityEngine.InputSystem;
using System.Collections;
using UnityEngine.XR.Interaction.Toolkit;
using Sirenix.OdinInspector;
using ScriptableObjectArchitecture;
using HouseOfCards.Player;
using RichPackage;
using CommonUsages = UnityEngine.XR.CommonUsages;
// Richard Osborn
// A very simple, serializable database for storing primitive values in a scriptable object.
using System;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// A simple database object that stores key-value pairs of primitive types.
/// </summary>
@Monsoonexe
Monsoonexe / AtomicCounter.cs
Last active November 25, 2022 19:05
An atomic, lock-free, thread-safe counter for C#
using System.Runtime.CompilerServices;
using System.Threading;
/// <summary>
/// Thread-safe counter.
/// </summary>
internal struct AtomicCounter
{
private int counter;