Skip to content

Instantly share code, notes, and snippets.

View kurtdekker's full-sized avatar

Kurt Dekker kurtdekker

View GitHub Profile
@kurtdekker
kurtdekker / PerformChangeOnAllScenes.cs
Created December 29, 2022 16:04
Perform a change on ALL of your scenes - BE CAREFUL!
using UnityEngine;
using UnityEditor.Callbacks;
using UnityEditor;
using UnityEditor.SceneManagement;
// @kurtdekker - 8:01 AM 12/29/2022
public class PerformChangeOnAllScenes
{
[MenuItem( itemName: "Assets/Perform Change On ALL Scenes")]
@kurtdekker
kurtdekker / DestroyOnAwake.cs
Created December 27, 2022 05:35
a way to put design elements in your Unity scene so they disappear when you play.
using UnityEngine;
// @kurtdekker - Attach this script to GameObjects you
// want to have in your scene for alignment and design,
// but you want to be destroyed during real gameplay.
public class DestroyOnAwake : MonoBehaviour
{
void Awake()
{
@kurtdekker
kurtdekker / MakeGeometryDoubleSided.cs
Created December 21, 2022 17:24
Simple runtime geometry double-sider (duplicate geometry, flips triangles)
using UnityEngine;
// @kurtdekker - simple runtime geometry double-siding mechanism.
//
// Place or add this Component to things with at
// least a MeshFilter on them.
//
// Presently only for single-submesh geometry.
//
// Copies vertex position and uv, then recalculates
@kurtdekker
kurtdekker / OverlayBlocker.cs
Last active October 12, 2022 17:07
Overlay input-blocking facility for Unity3D (input / click blocker / inhibitor)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker
//
// Purpose:
// - to inhibit processing of input whenever a popup is enabled
//
// To use:
@kurtdekker
kurtdekker / MachinegunSound.cs
Created October 12, 2022 13:55
Machinegun Sound (automatic gunfire) synthesis in Unity3D
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker - synthesizes a cheesy machinegun sound
//
// DO NOT PUT THIS IN ANY SCENE!!!!
//
// Instead, simply use it by calling:
//
@kurtdekker
kurtdekker / CloneAndFlipTriangles.cs
Created September 21, 2022 20:54
Clones and flips a piece of geometry, optionally using another material
using UnityEngine;
// @kurtdekker
//
// Place on a MeshFilter / MeshRenderer GameObject.
//
// This will:
// - duplicate the entire GameObject via Instantiate
// (and obviously its children; those are ignored!)
// - parent it to the same place the original was
@kurtdekker
kurtdekker / MakeGeometryDoubleSided.cs
Last active September 22, 2022 10:53
Makes geometry double-sided by re-winding copies of each triangle to face the other way
using UnityEngine;
// @kurtdekker - quick double-siding mechanism.
//
// Place or add this Component to things with at
// least a MeshFilter on them.
//
// Presently only for single-submesh geometry.
[RequireComponent( typeof( MeshFilter))]
@kurtdekker
kurtdekker / SpawnOnChristmas.cs
Created September 17, 2022 13:39
Examples of ultra-simple seasonal behavior differences
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker - this is part of Jetpack Kurt
//
// Spawns different items during certain seasons, in this case Christmas.
//
// To use:
// - place on empty active GameObject in your prefab or scene
@kurtdekker
kurtdekker / HeadNodYesSensor.cs
Last active February 16, 2024 10:21
Head shake no and nod yes gesture detector
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker - head nod yes sensor
//
// To use:
// Put this on a mouse-controlled FPS camera and it can detect:
// - up/down "head nods yes."
// Optionally give it an audio to play
@kurtdekker
kurtdekker / Comments.cs
Created July 22, 2022 17:31
leave comments all over your Unity scenes / prefabs
using UnityEngine;
// @kurtdekker - drop this script on on any GameObject (as many
// times as you like) and fill out the Text field.
public class Comments : MonoBehaviour
{
[Multiline]
public string Text = "< fill me out! >";
}