Skip to content

Instantly share code, notes, and snippets.

View SpritePropertyDrawer.cs
using UnityEngine;
using UnityEditor;
public class SpritePropertyDrawer : PropertyDrawer
public override float GetPropertyHeight(SerializedProperty property, GUIContent labelN)
if (property.objectReferenceValue != null)
darktable / Helper.cs
Created Jun 8, 2019
A utility script to find every component of a particular type in a scene. Not sure what the results will be if you have multiple additive scenes loaded.
View Helper.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Helper : MonoBehaviour
public static List<T> FindThemAll<T>(bool includeInactive = false) where T : UnityEngine.Component
var scene = SceneManager.GetActiveScene();
darktable / .hgignore
Created Feb 20, 2012
hg: Starter hgignore file for Unity3D projects
View .hgignore
syntax: glob
syntax: regexp
darktable / PostprocessBuildPlayer.cs
Created Jul 24, 2012
Unity3D: C# replacement for the python version of PostprocessBuildPlayer
View PostprocessBuildPlayer.cs
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEditor.Callbacks;
using System.IO;
public class PostprocessBuildPlayer : ScriptableObject {
static void OnPostprocessBuildPlayer(BuildTarget target, string buildPath) {
darktable / GUIScaler.cs
Created Mar 11, 2012
Unity3D: script to automatically scale gui elements on high dpi devices (like iPhone 4 or iPad 3rd Generation).
View GUIScaler.cs
using UnityEngine;
using System.Collections;
namespace UnityEngine {
/// <summary>
/// Usage:
/// (optional) Call GUIScaler.Initialize() in Start(), Awake() or OnEnable() (only needed once)
/// Call GUIScaler.Begin() at the top of your OnGUI() methods
/// Call GUIScaler.End() at the bottom of your OnGUI() methods
darktable / CodeProfiler.cs
Created Mar 14, 2012
Unity3D: Tweaked version of @robotduck's CodeProfiler script.
View CodeProfiler.cs
// You can switch to a regular Update() loop
// if you comment out this line. (makes debugging easier)
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using UnityEngine;
using Debug = UnityEngine.Debug;
darktable / UpdateXcodeProject.cs
Created Oct 5, 2012
Unity3D: Post-process script that copies the xcode build output to another directory. Used for updating a heavily modified Xcode project without stomping on changes to, Info.plist, etc.
View UpdateXcodeProject.cs
/* **************************************************************************
Copyright 2012 Calvin Rien
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
darktable / SingleComponentCheck.cs
Created Aug 30, 2012
Unity3D: Snippet that prevents adding a component multiple times to a GameObject in the Unity Editor.
View SingleComponentCheck.cs
void SingleComponentCheck() {
var components = gameObject.GetComponents(this.GetType());
foreach (var component in components) {
if (component == this) continue;
UnityEditor.EditorUtility.DisplayDialog("Can't add the same component multiple times!",
string.Format("The component {0} can't be added because {1} already contains the same component.", this.GetType(),,
darktable / minijsonjsdemo.js
Created Aug 30, 2012
Unity3D: Example of using MiniJSON in UnityScript (JavaScript).
View minijsonjsdemo.js
#pragma strict
import MiniJSON;
import System.Collections.Generic;
function Start () {
var jsonString = "{ \"array\": [1.44,2,3], " +
"\"object\": {\"key1\":\"value1\", \"key2\":256}, " +
"\"string\": \"The quick brown fox \\\"jumps\\\" over the lazy dog \", " +
"\"unicode\": \"\\u3041 Men\\u00fa sesi\\u00f3n\", " +
"\"int\": 65536, " +
import struct
import SocketServer
from base64 import b64encode
from hashlib import sha1
from mimetools import Message
from StringIO import StringIO
# import threading
class WebSocketsHandler(SocketServer.StreamRequestHandler):