Skip to content

Instantly share code, notes, and snippets.

@darktable
darktable / .hgignore
Created February 20, 2012 03:40
hg: Starter hgignore file for Unity3D projects
syntax: glob
.DS_Store
*.sln
*.userprefs
*.csproj
*.pidb
*.unitypackage
syntax: regexp
^Build/.*
@darktable
darktable / Helper.cs
Created June 8, 2019 15:48
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.
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();
using UnityEngine;
using UnityEditor;
[CustomPropertyDrawer(typeof(Sprite))]
public class SpritePropertyDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent labelN)
{
if (property.objectReferenceValue != null)
{
@darktable
darktable / zwoptex.json
Created December 7, 2011 21:39
Zwoptex: Template for exporting zwoptex data in JSON format.
{"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 }}},
using System;
using System.IO;
using System.Runtime.CompilerServices;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;
/// <summary>
/// Hierarchy Window Group Header
/// http://diegogiacomelli.com.br/unitytips-changing-the-style-of-the-hierarchy-window-group-header/
@darktable
darktable / SelectWithLayer.cs
Created February 23, 2012 03:49
Unity3D: editor script to select all objects that are in a particular layer.
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 / IncrementBuildVersion.cs
Created September 8, 2012 21:43
Unity3d: Post-process script that increments revision number of iPhone and Android builds.
/* **************************************************************************
Copyright 2012 Calvin Rien
(http://the.darktable.com)
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
http://www.apache.org/licenses/LICENSE-2.0
@darktable
darktable / PostBuildLog.cs
Created August 29, 2012 01:34
Unity3D: Post-process script that includes a build.log file containing the build summary in the output directory. Based on a method in BuildManager.
/* **************************************************************************
Copyright 2012 Calvin Rien
(http://the.darktable.com)
Derived from a method in BuildManager, part of
VoxelBoy's Unite 2012 Advanced Editor Scripting Talk.
(http://bit.ly/EditorScripting)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@darktable
darktable / MaterialGradientDrawer.cs
Created October 20, 2021 17:44 — forked from totallyRonja/MaterialGradientDrawer.cs
A Material Property Drawer for the [Gradient] attribute which lets you edit gradients and adds them to the shader as textures. More information here: https://twitter.com/totallyRonja/status/1368704187580682240
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class MaterialGradientDrawer : MaterialPropertyDrawer {
private int resolution;
@darktable
darktable / GUIScaler.cs
Created March 11, 2012 23:36
Unity3D: script to automatically scale gui elements on high dpi devices (like iPhone 4 or iPad 3rd Generation).
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