Skip to content

Instantly share code, notes, and snippets.

@darkon76
darkon76 / OrtographicDrag.cs
Last active April 3, 2023 19:54
Unity Drag.
using UnityEngine;
using UnityEngine.EventSystems;
public class OrtographicDrag: MonoBehaviour, IDragHandler
{
private Camera _mainCamera;
public float DistanceToCamera;
public void OnDrag(PointerEventData eventData)
{
@Reyth3
Reyth3 / TimeManipulation.cs
Created September 26, 2017 12:35
Time Passage Handling in Unity3D
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TimeManipulation : MonoBehaviour {
#region Fields and Events
private static TimeManipulation _current;
@paullj
paullj / JSONEditor.cs
Last active October 16, 2020 08:57
A JSON Editor in the inspector. Preview and more information in comments 🙂
using System.IO;
using System.Linq;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
using UnityEditor;
using System;
@yagero
yagero / UtilsEnum.cs
Created August 28, 2017 09:48
Enum.HasFlag in .NET 2 / Unity 5
public static class UtilsEnum
{
public static bool HasFlag(this Enum mask, Enum flags) // Same behavior than Enum.HasFlag is .NET 4
{
#if DEBUG
if (mask.GetType() != flags.GetType())
throw new System.ArgumentException(
string.Format("The argument type, '{0}', is not the same as the enum type '{1}'.",
flags.GetType(), mask.GetType()));
#endif
@Democide
Democide / ShortcutToggleObjectActivation.cs
Last active October 23, 2021 12:04
Simple Unity script to toggle the activation state of selected game objects
using UnityEngine;
using System.Collections;
using UnityEditor;
public static class ShortcutToggleObjectActivation
{
// LEFT ALT + LEFT SHIFT + A to toggle active state of selected GameObjects
[MenuItem("Shortcuts/Toggle Selected GameObjects Active #&a")]
static void SaveGameOpenFolder()
{
@dvddarias
dvddarias / SingletonScriptableObject.cs
Last active February 27, 2025 13:44
Better Unity Singleton Class
/************************************************************
* Better Singleton by David Darias
* Use as you like - credit where due would be appreciated :D
* Licence: WTFPL V2, Dec 2014
* Tested on Unity v5.6.0 (should work on earlier versions)
* 03/02/2017 - v1.1
* **********************************************************/
using System;
using UnityEngine;
@CustomPhase
CustomPhase / MidiReader.cs
Last active May 3, 2024 13:04
MidiReader.cs
using UnityEngine;
using System.Collections;
using NAudio.Midi;
using System.IO;
using System.Linq;
public class MidiReader : MonoBehaviour {
public MidiFile midi;
@xDavidLeon
xDavidLeon / ToonDeferredShading2017.shader
Created May 18, 2017 14:43
Unity 5.6 Deferred Cel Shading Modification
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
// Modifications by David Leon. Copyright (c) 2017 Lince Works SL. MIT license (see license.txt)
Shader "ToonDeferredShading2017" {
Properties {
_LightTexture0 ("", any) = "" {}
_LightTextureB0 ("", 2D) = "" {}
_ShadowMapTexture ("", any) = "" {}
_SrcBlend ("", Float) = 1
_DstBlend ("", Float) = 1
@simdezimon
simdezimon / VRNightVision.cs
Last active January 24, 2025 19:23
VR Night Vision Shader
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class VRNightVision : MonoBehaviour {
private Material material;
private Camera cam;
[Tooltip("Grain size in pixel. Should be greater than 1 with supersampling.")]
@spaceemotion
spaceemotion / EditorWindowFinder.cs
Created March 28, 2017 21:08
Displays a window that lists all available EditorWindows inside the Unity Editor.
using System;
using System.Reflection;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class EditorWindowFinder : EditorWindow
{