Skip to content

Instantly share code, notes, and snippets.

@karljj1
karljj1 / ObjectChangeEventsExample.cs
Last active November 6, 2024 10:39
Example of how to use ObjectChangeEvents in Unity
using System.Text;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class ObjectChangeEventsExample
{
static ObjectChangeEventsExample()
{
ObjectChangeEvents.changesPublished += ChangesPublished;
@KarlRamstedt
KarlRamstedt / SceneRefAttribute.cs
Created January 4, 2020 16:34
Unity Scene Reference Attribute
using UnityEngine;
namespace ModularOptions {
/// <summary>
/// Uses a CustomPropertyDrawer to draw a string field as a SceneAsset object field.
/// </summary>
/// <example><code>
/// [SceneRef] string mainMenu;
/// </code></example>
[System.AttributeUsage(System.AttributeTargets.Field)]
@R-WebsterNoble
R-WebsterNoble / SavWav.cs
Last active November 8, 2024 02:15 — forked from darktable/SavWav.cs
Unity3D: script to save an AudioClip as a .wav file.
// Copyright (c) 2012 Calvin Rien
// http://the.darktable.com
//
// This software is provided 'as-is', without any express or implied warranty. In
// no event will the authors be held liable for any damages arising from the use
// of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
@steven2358
steven2358 / ffmpeg.md
Last active March 12, 2025 01:04
FFmpeg cheat sheet
@partlyhuman
partlyhuman / GotoScene.cs
Last active May 27, 2021 01:22
Unity Keyboard Scene Switcher
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace com.hololabs.editor
{
public static class GotoScene
{
@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;
@LotteMakesStuff
LotteMakesStuff / TrafficLightAttribute.cs
Last active February 2, 2024 15:58
TrafficLight control/layout/property drawer: Adds a new editor control that draws lil Traffic Lights in the inspector. its really useful for visualizing state. For example, checkboxes can be hard to read at a glace, but a Red or Green status light is easy! Recommend you use the attached package, as it has all the icon image files.
// Non Editor code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class TrafficLightAttribute : PropertyAttribute
{
public bool DrawLabel = true;
public string CustomLabel;
public bool AlsoDrawDefault;
@LotteMakesStuff
LotteMakesStuff / EditorCoroutineRunner.cs
Last active August 28, 2024 19:09
Run stuff in the editor with all the convenience of co-routines! Add a status UI super easily to see readouts what your long running code is actually doing! nice~ There is a short API demo at the top of the class. This is a prefect companion for my inspector buttons https://gist.github.com/LotteMakesStuff/dd785ff49b2a5048bb60333a6a125187
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class EditorCoroutineRunner
{
[MenuItem("Window/Lotte's Coroutine Runner: Demo")]
@derwodaso
derwodaso / ScriptingDefineSymbolToggler.cs
Created March 14, 2017 10:34
Disable / Enable ScriptingDefineSymbolds from menu
/* To avoid performance issues caused by string constructions when logging stuff
* to the console, simply surround the code with the the following:
*
* #if DEBUG_LOGGING
* Debug.Log("my" + numer.ToString("0.00") " super" + " expensive " + " string building code");
* #endif
*
* When creating a non-debug build or testing the game for performance, simply disable
* the debug messages from the Unity menu (menu name can be simply changed below).
*/
@khalladay
khalladay / PackRGB.cs
Created February 21, 2017 14:40
PackRGBTool
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEditor;
public class PackToRGB : EditorWindow
{
private Texture2D[] RGB;