This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using UnityEngine; | |
/// <summary> | |
/// A replacement for Unity's PlayerPrefs that stores data in a JSON file. | |
/// </summary> | |
[Serializable] | |
public class JsonPlayerPrefs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// @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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
// @kurtdekker | |
public static class GeometryHelpers | |
{ | |
public static void ApplyMeshScaling( GameObject go, float scale) | |
{ | |
var MeshFilters = go.GetComponentsInChildren<MeshFilter>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); |