Skip to content

Instantly share code, notes, and snippets.

@darktable
darktable / DebugConsole.cs
Created December 1, 2011 00:25
Unity3D: Heavily modified version of Jeremy Hollingsworth's DebugConsole script.
#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)
@darktable
darktable / ProjectAssetPostprocessor.cs
Created April 20, 2012 03:37 — forked from hoesing/ProjectAssetPostprocessor.cs
Unity asset pre/postprocessor for applying asset defaults by path.
// 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 / DoomGlow.cs
Created June 20, 2022 11:53 — forked from TiliSleepStealer/DoomGlow.cs
Doom glow - fake volumetric light glow effect in Unity by Tili_us
// This file is in the public domain. Where
// a public domain declaration is not recognized, you are granted
// a license to freely use, modify, and redistribute this file in
// any way you choose.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Unity remake of a fake volumetric light glow effect
@darktable
darktable / UnityGetNativeAndroidVersion
Created March 4, 2022 22:03 — forked from kibotu/UnityGetNativeAndroidVersion
Get versionCode and versionName with unity.
//int vesioncode = context().getPackageManager().getPackageInfo(context().getPackageName(), 0).versionCode;
public static int GetVersionCode() {
AndroidJavaClass contextCls = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject context = contextCls.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageMngr = context.Call<AndroidJavaObject>("getPackageManager");
string packageName = context.Call<string>("getPackageName");
AndroidJavaObject packageInfo = packageMngr.Call<AndroidJavaObject>("getPackageInfo", packageName, 0);
return packageInfo.Get<int>("versionCode");
}
@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
@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 / 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 / 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 / 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);
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/