Skip to content

Instantly share code, notes, and snippets.

Emil Johansen AngryAnt

Block or report user

Report or block AngryAnt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AngryAnt
AngryAnt / ConstructorIsh.cs
Created Oct 16, 2013
For when you really want that one line for instantiation and initialisation.
View ConstructorIsh.cs
class MyBehaviour : MonoBehaviour
{
public MyBehaviour Init (int some, float parameters)
{
//...
return this;
}
}
@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 / 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 / Controllers.cs
Created Aug 4, 2013
Adding axes to the Unity input manager. As described in the post http://angryant.com/2013/08/04/Unity-Hacks-Dual-sticks/
View Controllers.cs
public static void AddAxis (AxisDefinition axis)
{
if (AxisDefined (axis.name))
{
throw new System.ArgumentException (string.Format ("Specified axis \"{0}\" already exists", axis.name));
}
SerializedObject serializedObject = new SerializedObject (AssetDatabase.LoadAllAssetsAtPath ("ProjectSettings/InputManager.asset")[0]);
SerializedProperty axesProperty = serializedObject.FindProperty ("m_Axes");
@AngryAnt
AngryAnt / Digits.cs
Last active Dec 20, 2015
Display an integral value in separate textures of digits. Untested.
View Digits.cs
Texture2D[] m_Numbers, m_Digits;
void SetValue (int value)
{
if (value >= Mathf.Pow (10, m_Digits.Length))
{
Debug.LogError ("Value overflow: Unable to display value: " + value);
}
for (int i = m_Digits.Length - 1; i >= 0; --i)
@AngryAnt
AngryAnt / Control-OnGesture.cs
Created Jul 19, 2013
Example of an OnGesture handler - handling left and right swipes as served up by the TouchGestures component.
View Control-OnGesture.cs
void OnGesture (Gesture gesture)
{
switch (gesture.type)
{
case GestureType.Swipe:
if (Vector2.Dot (gesture.direction, new Vector2 (1.0f, 0.0f)) > 0.8f)
{
Previous ();
}
else if (Vector2.Dot (gesture.direction, new Vector2 (-1.0f, 0.0f)) > 0.8f)
@AngryAnt
AngryAnt / OnRenderTextureGUI.cs
Created Jul 12, 2013
Example code for "OnRenderTextureGUI" blog post on AngryAnt.com
View OnRenderTextureGUI.cs
void OnGUI ()
{
BeginRenderTextureGUI (m_TargetTexture);
GUILayout.Box ("This box goes on a render texture!");
EndRenderTextureGUI ();
}
@AngryAnt
AngryAnt / Broadcaster.cs
Created Jun 7, 2013
Broadcaster / Seeker basics for sharing and joining games on your local network. Example code for "The implicit local network interface" blog post on AngryAnt.com
View Broadcaster.cs
if (m_BroadcastTimer == null)
// Setup broadcast of hosting service
{
m_BroadcastSocket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
try
{
IPAddress broadcastGroup = IPAddress.Parse (kBroadcastGroup);
m_BroadcastSocket.SetSocketOption (
@AngryAnt
AngryAnt / Pickup.cs
Created May 28, 2013
Example of a server-side managed pickup base behaviour for Unity networking.
View Pickup.cs
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (Collider))]
[RequireComponent (typeof (NetworkView))]
public abstract class Pickup : MonoBehaviour
{
bool available;
@AngryAnt
AngryAnt / Abstraction.cs
Last active Nov 7, 2017
The Behave runtime.
View Abstraction.cs
public BehaveResult TickShuffleAction (Tree sender)
{
return m_ShuffleTree.Tick ();
}
public void ResetShuffleAction (Tree sender)
{
m_ShuffleTree.Reset ();
}
You can’t perform that action at this time.