Skip to content

Instantly share code, notes, and snippets.

Avatar

Emil Johansen AngryAnt

View GitHub Profile
@AngryAnt
AngryAnt / TerriblyHackyLog.cs
Created Aug 7, 2013
Abusing reflection and the internal Unity player build error function to get stacktrace-less error logs. Not recommended for anything sane.
View TerriblyHackyLog.cs
using UnityEngine;
using System.Reflection;
public class TerriblyHackyLog : MonoBehaviour
{
void Start ()
{
Log ("Aaaaarrrrgh!");
}
@AngryAnt
AngryAnt / TotalBounds.cs
Created Aug 18, 2011
Getting the total rendering bounds of a hierarchy of renderers.
View TotalBounds.cs
private Bounds bounds;
void Start ()
{
bounds = new Bounds (transform.position, Vector3.one);
Renderer[] renderers = GetComponentsInChildren<Renderer> ();
foreach (Renderer renderer in renderers)
{
bounds.Encapsulate (renderer.bounds);
@AngryAnt
AngryAnt / user-callback
Created Dec 11, 2019
User callback script for BackInTime handling mount & unmount of encrypted backup target and using the modify date of a file to communicate last snapshot date.
View user-callback
#!/bin/bash
# Copyright (c) 2012-2015 Germar Reitze
# Mount/unmount implementation 2019 Emil "AngryAnt" Johansen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@AngryAnt
AngryAnt / EditorWindowExample.cs
Created Jun 15, 2012
EditorWindowExample from the Unity Asia Bootcamp 12 talk "Streamlining your Unity editor". A simple node based editor.
View EditorWindowExample.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class EditorWindowExample : EditorWindow
{
List<Node> nodes = new List<Node> ();
@AngryAnt
AngryAnt / MultiScene.cs
Created Aug 9, 2013
This utility lets you easily combine two scenes into one.
View MultiScene.cs
using UnityEngine;
using UnityEditor;
using System.IO;
public class MultiScene
{
[MenuItem ("File/Combine Scenes")]
static void Combine ()
{
@AngryAnt
AngryAnt / DualDisplay.cs
Last active Aug 27, 2019
Example use of the Unity 4.1 AirPlay API - gives a setup with the iOS device as controller of the remote display.
View DualDisplay.cs
using UnityEngine;
using System.Collections;
/*
Runtime use:
To be available, AirPlay needs to be switched on for the device either via a native AirPlay UI component or
via the global AirPlay mirroring setting. Your options are:
A: Modify your Xcode project to layer a native AirPlay Cocoa control somewhere over your Unity content.
View CoroutineData.cs
//#define DEBUG_THREADING
using UnityEngine;
using System.Collections;
using System.Threading;
using System.Reflection;
public delegate IEnumerator MonitorCoroutine<T> (CoroutineData<T> data);
View Jerboa.swift
//
// main.swift
// Jerboa
//
// Created by Emil Johansen on 19/01/2019.
// Copyright © 2019 AngryAnt. All rights reserved.
//
// https://en.wikipedia.org/wiki/Jerboa
//
@AngryAnt
AngryAnt / Build.sh
Created Sep 30, 2012
Example code for "Downloading the hydra" blog post on AngryAnt.com
View Build.sh
mcs -target:library -out:MyAssembly.dll -r:/Applications/Unity/Unity.app/Contents/Frameworks/UnityEngine.dll MyAssembly.cs
@AngryAnt
AngryAnt / Styles.cs
Created Jun 29, 2012
Handy utility functions for creating solid colour textures for GUI use.
View Styles.cs
// Usage:
m_SideBarTexture = CreateTexture (CreateColor ("#30433C"));
// The goodness:
static Color CreateColor (string hexCode, float alpha = 1.0f)
{
if (hexCode.Length == 7 && hexCode[0] == '#')
{
You can’t perform that action at this time.