Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
AngryAnt / DualDisplay.cs
Last active Oct 23, 2022
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.
@AngryAnt
AngryAnt / MissingHassModule.sh
Last active Feb 28, 2022
List the home assistant modules reported missing by the nixos home assistant service since it was last started.
View MissingHassModule.sh
#!/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 / 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 / Drawer.cs
Last active Oct 6, 2021
Attempting to override the default UnityEvent drawer.
View Drawer.cs
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine.Events;
using System.Reflection;
namespace Test
{
[CustomPropertyDrawer (typeof (UnityEventBase), true)]
View Multiply.cs
using UnityEngine;
using System.Collections;
public class Multiply : MonoBehaviour
{
public Camera source, destination;
private RenderTexture renderTexture;
@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 ()
{