Skip to content

Instantly share code, notes, and snippets.

@randalfien
randalfien / MarkUnused.cs
Last active October 3, 2024 01:52
Unity Mark Unused Assets
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public class MarkUnused
{
private const string UnusedLabel = "Unused"; // All unused assets will be tagged with this label
@JohannesMP
JohannesMP / LICENSE
Last active October 5, 2025 19:01
[Unity3D] A Reliable, user-friendly way to reference SceneAssets by script.
/*******************************************************************************
* Don't Be a Jerk: The Open Source Software License.
* Adapted from: https://github.com/evantahler/Dont-be-a-Jerk
*******************************************************************************
* _I_ am the software author - JohannesMP on Github.
* _You_ are the user of this software. You might be a _we_, and that's OK!
*
* This is free, open source software. I will never charge you to use,
* license, or obtain this software. Doing so would make me a jerk.
*
@unitycoder
unitycoder / DrawBounds.cs
Last active February 12, 2025 04:14
Draw Bounds with Debug.DrawLine , Draw Box, Draw Runtime Gizmos
void DrawBounds(Bounds b, float delay=0)
{
// bottom
var p1 = new Vector3(b.min.x, b.min.y, b.min.z);
var p2 = new Vector3(b.max.x, b.min.y, b.min.z);
var p3 = new Vector3(b.max.x, b.min.y, b.max.z);
var p4 = new Vector3(b.min.x, b.min.y, b.max.z);
Debug.DrawLine(p1, p2, Color.blue, delay);
Debug.DrawLine(p2, p3, Color.red, delay);
@hasanbayatme
hasanbayatme / MinMax.cs
Last active October 11, 2025 15:47
Unity Min Max Slider Implementation
using System;
using UnityEngine;
[Serializable]
public struct MinMax
{
[SerializeField]
private float min;
[SerializeField]
@ditzel
ditzel / MathParabola.cs
Last active October 16, 2025 15:26
A simple Math class to calculate a point in 2D or 3D space lying on a parabola. And a more complex parabola controller that you can put on an object.
using UnityEngine;
using System;
public class MathParabola
{
public static Vector3 Parabola(Vector3 start, Vector3 end, float height, float t)
{
Func<float, float> f = x => -4 * height * x * x + 4 * height * x;
@LotteMakesStuff
LotteMakesStuff / PlayerLoop.cs
Last active September 24, 2024 06:38
Player Loop Visualizer: Built to explore the new PlayerLoopSystem api in Unity 2018.1b2. This tool shows you all the PlayerLoop systems that unity uses to update a frame, and demos how to add your own and even remove systems from the player loop. For more info see the patreon post https://www.patreon.com/posts/unity-2018-1-16336053
// Put this in an editor folder
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.LowLevel;
using UnityEngine.Profiling;
@LotteMakesStuff
LotteMakesStuff / MinMaxAttribute.cs
Last active August 12, 2025 17:41
MinMax property drawer for Unity - Add a [MinMax] attribute to a property to draw a useful min/max setting slider.
// NOTE DONT put in an editor folder
using UnityEngine;
public class MinMaxAttribute : PropertyAttribute
{
public float MinLimit = 0;
public float MaxLimit = 1;
public bool ShowEditRange;
public bool ShowDebugValues;
@Hertzole
Hertzole / SceneObject.cs
Last active May 4, 2024 13:04
Unity scene object to easily assign scenes in the inspector.
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
[System.Serializable]
public class SceneObject
{
[SerializeField]
private string m_SceneName;
@pmunin
pmunin / PriorityQueue.cs
Last active March 29, 2018 16:28
Simple .NET PriorityQueue based on SortedDictionary<TKey, Queue<TItem>> (BST) behind the scene
//Latest version is here: https://gist.github.com/affc23dd89950e67ece9ca3b19b9508a.git
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace PriorityQueueUtils
{
/// <summary>
/// Queue contract
@ryanc-unity
ryanc-unity / AsyncBundleLoader.cs
Last active August 22, 2022 14:55
Dummy object generator for project testing
using System.Collections;
using System.IO;
using UnityEngine;
public class AsyncBundleLoader : MonoBehaviour
{
// Used for visual debugging as to not generate unnecessary allocations
public GameObject worldLight;
// Private fields to keep track of loaded objects