Skip to content

Instantly share code, notes, and snippets.

View AngryAnt's full-sized avatar

Emil "AngryAnt" Johansen AngryAnt

View GitHub Profile
@AngryAnt
AngryAnt / DualDisplay.cs
Last active January 24, 2024 08:26
Example use of the Unity 4.1 AirPlay API - gives a setup with the iOS device as controller of the remote display.
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.
@AngryAnt
AngryAnt / MissingHassModule.sh
Last active July 31, 2023 17:51
List the home assistant modules reported missing by the nixos home assistant service since it was last started.
#!/usr/bin/env bash
set -euo pipefail
serviceName="home-assistant.service"
startTime=$(systemctl show -p ActiveEnterTimestamp "$serviceName")
startTime=$(echo $startTime | awk '{print $2 $3}')
echo "Missing modules reported since $serviceName start at $startTime:"
@AngryAnt
AngryAnt / TerriblyHackyLog.cs
Created August 7, 2013 18:04
Abusing reflection and the internal Unity player build error function to get stacktrace-less error logs. Not recommended for anything sane.
using UnityEngine;
using System.Reflection;
public class TerriblyHackyLog : MonoBehaviour
{
void Start ()
{
Log ("Aaaaarrrrgh!");
}
@AngryAnt
AngryAnt / Build.sh
Created September 30, 2012 07:21
Example code for "Downloading the hydra" blog post on AngryAnt.com
mcs -target:library -out:MyAssembly.dll -r:/Applications/Unity/Unity.app/Contents/Frameworks/UnityEngine.dll MyAssembly.cs
@AngryAnt
AngryAnt / Drawer.cs
Last active October 6, 2021 20:55
Attempting to override the default UnityEvent drawer.
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine.Events;
using System.Reflection;
namespace Test
{
[CustomPropertyDrawer (typeof (UnityEventBase), true)]
@AngryAnt
AngryAnt / Multiply.cs
Created August 1, 2011 14:58
A simple example of a multiply blend in Unity. http://en.wikipedia.org/wiki/Blend_modes#Multiply
using UnityEngine;
using System.Collections;
public class Multiply : MonoBehaviour
{
public Camera source, destination;
private RenderTexture renderTexture;
@AngryAnt
AngryAnt / TotalBounds.cs
Created August 18, 2011 12:49
Getting the total rendering bounds of a hierarchy of renderers.
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 December 11, 2019 08:20
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.
#!/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 June 15, 2012 08:30
EditorWindowExample from the Unity Asia Bootcamp 12 talk "Streamlining your Unity editor". A simple node based editor.
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 August 9, 2013 10:03
This utility lets you easily combine two scenes into one.
using UnityEngine;
using UnityEditor;
using System.IO;
public class MultiScene
{
[MenuItem ("File/Combine Scenes")]
static void Combine ()
{