Skip to content

Instantly share code, notes, and snippets.

View AngryAnt's full-sized avatar

Emil "AngryAnt" Johansen AngryAnt

View GitHub Profile
@AngryAnt
AngryAnt / Pickup.cs
Created May 28, 2013 10:08
Example of a server-side managed pickup base behaviour for Unity networking.
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (Collider))]
[RequireComponent (typeof (NetworkView))]
public abstract class Pickup : MonoBehaviour
{
bool available;
@AngryAnt
AngryAnt / Abstraction.cs
Last active November 7, 2017 08:10
The Behave runtime.
public BehaveResult TickShuffleAction (Tree sender)
{
return m_ShuffleTree.Tick ();
}
public void ResetShuffleAction (Tree sender)
{
m_ShuffleTree.Reset ();
}
@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 / PackageInfo.cs
Created November 8, 2012 09:19
Utility editor script for displaying a dialog message when it is imported. Useful for adding messages to asset store packages for instance. Rather than just showing a dialogue, this could also be used as a platform for running an actual package installer
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
public class PackageInfo
{
const string kTitle = "Notice", kMessage = "This package is the prettiest of them all.", kButton = "Ok", kPackageIdentifier = "AwesomePackage";
@AngryAnt
AngryAnt / RemoveInLoop.cs
Created October 10, 2012 08:29
Example showing how to remove an item in a list inside a loop using that list.
for (int i = 0; i < list.Count;)
{
GUILayout.Label (list[i].ToString ());
if (GUILayout.Button ("Delete"))
{
list.RemoveAt (i);
}
else
{
i++;
@AngryAnt
AngryAnt / Menu.cs
Created September 30, 2012 07:38
Example code for "Building a menu of delegates and enums" blog post on AngryAnt.com
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Menu : MonoBehaviour
{
delegate void OnGUIImplementation();
public enum MenuState {Main,Settings,Credits};
public struct Settings
{
@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 / CopyInspector.cs
Last active October 11, 2015 04:57
Example code for "CopyInspector" blog post on AngryAnt.com
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class CopyInspector : Editor
{
static System.Type m_OriginalType;
static Dictionary <PropertyInfo, object> m_Values;
@AngryAnt
AngryAnt / DataObject.cs
Created September 29, 2012 18:05
Example code for "GUI drag drop" blog post on AngryAnt.com
using UnityEngine;
using System.Collections;
public class DataObject : GUIDraggableObject
// This class just has the capability of being dragged in GUI - it could be any type of generic data class
{
private string m_Name;
private int m_Value;
public DataObject (string name, int value, Vector2 position) : base (position)
@AngryAnt
AngryAnt / Utilities.cs
Created September 29, 2012 17:59
Example code for "Logging an entire GameObject" blog post on AngryAnt.com
using UnityEngine;
using System.Reflection;
public class Utilities
{
/* ... */
static void LogGameObject( GameObject gameObject, bool children )
{
Component[] components = gameObject.GetComponents( typeof( Component ) );