Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
AngryAnt / DualDisplay.cs
Last active October 23, 2022 19:06
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 February 28, 2022 19:27
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 September 30, 2012 07:21
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 October 6, 2021 20:55
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)]
@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
View Multiply.cs
using UnityEngine;
using System.Collections;
public class Multiply : MonoBehaviour
{
public Camera source, destination;
private RenderTexture renderTexture;
@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.
View TerriblyHackyLog.cs
using UnityEngine;
using System.Reflection;
public class TerriblyHackyLog : MonoBehaviour
{
void Start ()
{
Log ("Aaaaarrrrgh!");
}
@AngryAnt
AngryAnt / TotalBounds.cs
Created August 18, 2011 12:49
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 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.
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 June 15, 2012 08:30
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 August 9, 2013 10:03
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 ()
{