Skip to content

Instantly share code, notes, and snippets.

View kurtdekker's full-sized avatar

Kurt Dekker kurtdekker

View GitHub Profile
using UnityEngine;
using UnityEditor;
// @kurtdekker
// Make sure this is in an Editor folder!
public static class DuplicationHelpers
{
// duplicates the current object and puts it back right after the original.
[MenuItem( "Assets/Dupe Here FFS")]
@kurtdekker
kurtdekker / CheesyGrid.cs
Last active February 24, 2025 14:42
A super-cheesy 2D map / grid editor for Unity3D
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
// @kurtdekker - ultra Cheesy grid with in-built editor for Unity3D
//
// To use:
// make an empty game object
// drag this script on it
@kurtdekker
kurtdekker / SpinOnY.cs
Last active July 30, 2021 14:51
Spin an object on the Y axis in Unity3D.
using UnityEngine;
// @kurtdekker
// Place on a GameObject, set the desired rate of spin
public class SpinOnY : MonoBehaviour
{
[Header( "Degrees per second.")]
public float RateOfRotation = 200.0f;
using UnityEngine;
public class CallWhenTrue : MonoBehaviour
{
System.Func<bool> test;
System.Action action;
public static CallWhenTrue Create( System.Func<bool> test, System.Action action)
{
CallWhenTrue cwt = new GameObject("CallWhenTrue").AddComponent<CallWhenTrue>();
@kurtdekker
kurtdekker / MatchTerrainToColliders.cs
Created August 18, 2021 13:55
Matching Unity3D terrain to arbitrary colliders
//
// Script originally from user @Zer0cool at:
//
// https://forum.unity.com/threads/terrain-leveling.926483/
//
// Revamped by @kurtdekker as follows:
//
// - put this on the object (or object hierarchy) with colliders
// - drag the terrain reference into it
// - use the editor button to "Stamp"
using UnityEngine;
// @kurtdekker
public static class GeometryHelpers
{
public static void ApplyMeshScaling( GameObject go, float scale)
{
var MeshFilters = go.GetComponentsInChildren<MeshFilter>();
@kurtdekker
kurtdekker / GM.cs
Last active November 8, 2025 16:13
//
// @kurtdekker
//
// ULTRA-simple fully-static GameManager for simple arcade-style games.
//
// NOTE: you DO NOT place this file into any scene! It is a pure static data container.
//
// Usage:
// - at start of game call GM.InitGame()
// - when you earn points, call GM.AddPoints(1234);
@kurtdekker
kurtdekker / ReadInputManager.cs
Created September 20, 2021 22:14
Display and Test ALL Unity3D inputs (old Input System)
using UnityEngine;
using System.Collections;
using UnityEditor;
// @kurtdekker
// You must put this in an Editor folder!
// Once compiled, you must run it from Menu -> Assets -> ReadInputManager
public class ReadInputManager
@kurtdekker
kurtdekker / InGamePause.cs
Created October 10, 2021 15:58
Simple stateless in-game pause mechanism
using UnityEngine;
// @kurtdekker
// Ultra-simple clean stateless in-game pause/unpause mechanism.
// TODO:
// - put one of these script instances in your running game scene
// - be sure to set Time.timeScale = 1 when your game starts
public class InGamePause : MonoBehaviour
{
@kurtdekker
kurtdekker / ScaleOnFocus.cs
Created October 12, 2021 18:19
Simple focused-button animator
using UnityEngine;
using UnityEngine.EventSystems;
// @kurtdekker
// cheap and cheerful "increase the size of the focused button"
public class ScaleOnFocus : MonoBehaviour
{
[Header( "Percent increase +10%, etc.")]
public float PercentIncrease = 10;