Skip to content

Instantly share code, notes, and snippets.

View kurtdekker's full-sized avatar

Kurt Dekker kurtdekker

View GitHub Profile
@kurtdekker
kurtdekker / CallAfterDelay.cs
Last active March 22, 2024 07:11
Call After Delay - handy Unity3D coroutine to do something later
using UnityEngine;
using System.Collections;
public class CallAfterDelay : MonoBehaviour
{
float delay;
System.Action action;
// Will never call this frame, always the next frame at the earliest
public static CallAfterDelay Create( float delay, System.Action action)
@kurtdekker
kurtdekker / GameObjectCollection.cs
Last active December 11, 2023 14:42
GameObjectCollection.cs
using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
[CreateAssetMenu(menuName = "Collections/GameObjectCollection")]
public class GameObjectCollection : ScriptableObject
{
@kurtdekker
kurtdekker / SceneHelper.cs
Last active January 22, 2024 21:21
Scene helper for Unity additive loading.
/*
The following license supersedes all notices in the source code.
Copyright (c) 2021 Kurt Dekker/PLBM Games All rights reserved.
http://www.twitter.com/kurtdekker
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
// From: https://answers.unity.com/questions/801928/46-ui-making-a-button-transparent.html?childToView=851816
//
// @kurtdekker
//
// Touchable invisible non-drawing Graphic (usable with Buttons too):
//
// To make an invisible Button:
//
// 1. make a Button in the normal way
// 2. delete the "Text" GameObject which comes below a Button as standard
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// by @kurtdekker - to make a simple Unity singleton that has no
// predefined data associated with it, eg, a high score manager.
//
// To use: access with SingletonSimple.Instance
//
// To set up:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// by @kurtdekker - to make a Unity singleton that has some
// prefab-stored, data associated with it, eg a music manager
//
// To use: access with SingletonViaPrefab.Instance
//
// To set up:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// by @kurtdekker - handy example of simple persistent settings.
//
// To use, just use the variables like any other:
//
// SETTINGS.VolumeLevel = 1.0f;
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker
//
// This is to take any continuous quantity and change it from one value
// to another over time. This code is for floats. It can be adapted to work for:
//
// Vector2, Vector3, Vector3
// Originally from:
// http://forum.unity3d.com/threads/script-simple-script-that-automatically-adjust-anchor-to-gui-object-size-rect-transform.269690/
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using System.Collections;
public class AnchorExtensions : MonoBehaviour {
@kurtdekker
kurtdekker / DuplicationHelpers.cs
Last active May 24, 2023 03:14
Waypoint gizmo and waypoint manager
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")]