Skip to content

Instantly share code, notes, and snippets.

View kurtdekker's full-sized avatar

Kurt Dekker kurtdekker

View GitHub Profile
@kurtdekker
kurtdekker / StopTheAction.cs
Created July 16, 2021 00:36
A way to easily pause the action while dialogs are up
using UnityEngine;
// @kurtdekker
//
// For stopping your game during instantiated / enabled dialogs.
//
// To use: put this script on things that you want to
// stop your game action when they appear, like dialogs.
//
// You only need one instance of this script per dialog.
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 / 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>();
using UnityEngine;
// @kurtdekker
public static class GeometryHelpers
{
public static void ApplyMeshScaling( GameObject go, float scale)
{
var MeshFilters = go.GetComponentsInChildren<MeshFilter>();
@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;
@kurtdekker
kurtdekker / LateFollow.cs
Created November 18, 2021 22:04
Lets one object follow another object using only a positional offset
using UnityEngine;
// @kurtdekker
// Purpose: follows another Transform, maintaining the same offset from it.
// Useful for a detached health bar that follows a rotating ship (for instance).
public class LateFollow : MonoBehaviour
{
public Transform TargetToFollow;
Vector3 Offset;
@kurtdekker
kurtdekker / MakeGridOfSprites.cs
Created December 8, 2021 23:40
Editor script to make a grid of sprites, aka, poor man's tilemap
using UnityEngine;
using UnityEditor;
// @kurtdekker
// cheap and cheerful grid-of-sprites maker
// this is an editor-time application
// it assumes you will further manipulate this grid and DIRTY AND SAVE THE SCENE
// be sure to drop this into an Editor folder!
public class MakeGridOfSprites : EditorWindow