Skip to content

Instantly share code, notes, and snippets.

View kamgam's full-sized avatar

KAMGAM kamgam

View GitHub Profile
@kamgam
kamgam / ForceGameViewCursorLock.cs
Created October 2, 2025 15:52
Allows the game code for a short time to override the cursor lock behaviour even in the editor. Useful to test the Escape key even while in the editor.
#if UNITY_EDITOR
using UnityEditor;
using System.Reflection;
/// <summary>
/// Allows the game code for a short time to override the cursor lock behaviour even in the editor.
/// Usage:
/// // Call it like this after some input that should trigger capturing the cursor again.
/// #if UNITY_EDITOR
/// ForceGameViewCursorLock.AllowCursorLockOverrideForNSec(0.1f);
@kamgam
kamgam / FixedUpdateProxy.cs
Created July 4, 2023 07:31
A component that can be added to add a temporary callback for FixedUpdate.
using UnityEngine;
namespace Kamgam.HitMe
{
/// <summary>
/// A component that can be added to add a temporary callback for FixedUpdate.<br /><br />
/// Useful if you have many similar objects (same class) but only a few of them need the
/// FixedUpdate callback.
/// </summary>
public class FixedUpdateProxy : MonoBehaviour
@kamgam
kamgam / StartWithFirstScene.cs
Created April 19, 2023 08:48
This adds a simple on/off checkbox to the Tools menu that allows you to toggle between starting with the current scene or the first scene in the build settings.
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using UnityEditor.SceneManagement;
namespace Kamgam
{
/// <summary>
/// Start With First Scene<br />
@kamgam
kamgam / TriangleSelector.cs
Created January 7, 2023 12:06
Unity Editor Mesh Triangle selector (with caching)
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace Kamgam
{
public static class TriangleSelector
{
const float kMaxDistance = 1000f;