Skip to content

Instantly share code, notes, and snippets.

@darktable
darktable / ProjectAssetPostprocessor.cs
Created Apr 20, 2012 — forked from hoesing/ProjectAssetPostprocessor.cs
Unity asset pre/postprocessor for applying asset defaults by path.
View ProjectAssetPostprocessor.cs
// Drop this script in the Editor directory in your project (creating the Editor directory if it's not there yet)
// Then re-import the assets in the directories covered by this script (right click and reimport)
//
// I would replace my path checking with the path checking from this gist:
// https://gist.github.com/1842177
//
// The texture settings for icons might want to use some of his settings combined with mine as well
using UnityEngine;
@darktable
darktable / SavWav.cs
Created Apr 6, 2012
Unity3D: script to save an AudioClip as a .wav file.
View SavWav.cs
// 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,
// subject to the following restrictions:
@darktable
darktable / GUIMerge.cs
Created Mar 29, 2012
Unity3D: Script to merge multiple GUISkins into a single GUISkin with multiple custom styles.
View GUIMerge.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class GUIMerge : MonoBehaviour {
public GUISkin primary;
public GUISkin[] skins;
@darktable
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)
#define COROUTINE
//
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using UnityEngine;
using Debug = UnityEngine.Debug;
@darktable
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
darktable / SelectWithLayer.cs
Created Feb 23, 2012
Unity3D: editor script to select all objects that are in a particular layer.
View SelectWithLayer.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using DB = UnityEngine.Debug;
public class SelectWithLayer : ScriptableObject {
static void SelectLayer(int layerNum) {
var objs = Selection.GetFiltered(typeof(GameObject), SelectionMode.Deep);
@darktable
darktable / .hgignore
Created Feb 20, 2012
hg: Starter hgignore file for Unity3D projects
View .hgignore
syntax: glob
.DS_Store
*.sln
*.userprefs
*.csproj
*.pidb
*.unitypackage
syntax: regexp
^Build/.*
@darktable
darktable / IconPostprocessor.cs
Created Feb 16, 2012
Unity3D: Editor script to prevent images added to Assets/Platform from being compressed. (Requires Unity Pro?)
View IconPostprocessor.cs
using System.IO;
using UnityEditor;
using UnityEngine;
public class IconPostprocessor : AssetPostprocessor {
void OnPreprocessTexture () {
if (assetPath.ToLower().StartsWith(Path.Combine("assets", "platform"))) {
var ti = (TextureImporter) assetImporter;
@darktable
darktable / zwoptex.json
Created Dec 7, 2011
Zwoptex: Template for exporting zwoptex data in JSON format.
View zwoptex.json
{"frames": {
{% for sprite in spritesAndAliases %}
"{{ sprite.name }}":
{
"frame": {"x":{{ sprite.textureRectX }},"y":{{ sprite.textureRectY }},"w":{{ sprite.textureRectWidth }},"h":{{ sprite.textureRectHeight }}},
"rotated": {% if sprite.isRotated %}true{% else %}false{% /if %},
"trimmed": {% if sprite.isTrimmed %}true{% else %}false{% /if %},
"spriteSourceSize": {"x":0,"y":0,"w":{{ sprite.sourceSizeWidth }},"h":{{ sprite.sourceSizeHeight }}},
"sourceSize": {"w":{{ sprite.sourceSizeWidth }},"h":{{ sprite.sourceSizeHeight }}},
"spriteColorRect": {"x":{{ sprite.sourceColorRectX }},"y":{{ sprite.sourceColorRectY }},"w":{{ sprite.sourceColorRectWidth }},"h":{{ sprite.sourceColorRectHeight }}},
@darktable
darktable / DebugConsole.cs
Created Dec 1, 2011
Unity3D: Heavily modified version of Jeremy Hollingsworth's DebugConsole script.
View DebugConsole.cs
#define DEBUG_CONSOLE
#define DEBUG_LEVEL_LOG
#define DEBUG_LEVEL_WARN
#define DEBUG_LEVEL_ERROR
#if (UNITY_EDITOR || DEVELOPMENT_BUILD)
#define DEBUG
#endif
#if (UNITY_IOS || UNITY_ANDROID)