This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A collection of useful C# extension methods for the Unity engine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
@author AlexHuleatt | |
Generate a simple, connected dungeon. Focus is on rooms, not maze-like features. | |
Output of get_dungeon is two sets: | |
1. A set of (y,x) tuples representing the position of walls | |
2. A set of (y,x) tuples representing the walls removed to make doors | |
''' | |
from random import randint, sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.sebaslab.com/how-to-compress-and-decompress-binary-stream-in-unity/ | |
using ICSharpCode.SharpZipLib.BZip2; | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.IO; | |
static void Compress (string nameOfTheFileToSave, ISerializable objectToSerialize) | |
{ | |
using (FileStream fs = new FileStream(nameOfTheFileToSave, FileMode.Create)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class SimpleSoundManager:MonoBehaviour { | |
// Audio source | |
private AudioSource musicSrc; | |
private AudioSource effectSrc; | |
// Instance variable | |
private static SimpleSoundManager instance; | |
// Instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class MeshCut | |
{ | |
private static Plane blade; | |
private static Transform victim_transform; | |
private static Mesh victim_mesh; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
// This provides a library for stubbing and mocking C++ code as is. It works by requiring | |
// explicit hooks to be inserted into the code that is to be mocked. In a regular build, | |
// these hooks will do nothing. In a testing build, they will expand to calls into the | |
// framework here to allow the code being executed to be hijacked from outside. | |
// | |
// NOTE: Thread-safety! Arranging fakes must be done on a single thread. Using fakes can | |
// be done from multiple threads concurrently. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//originally adopted from | |
//http://answers.unity3d.com/questions/447701/event-for-unity-editor-pause-and-playstop-events.html | |
//with a few modifications which makes the event firing nicer and cleaner | |
//Usage Example : | |
// | |
//using UnityEditor; | |
//using UnityEngine; | |
// | |
//[InitializeOnLoad] | |
//public class SingleEntryPoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
public class Force2DSound:AssetPostprocessor { | |
public void OnPreprocessAudio() { | |
AudioImporter ai = assetImporter as AudioImporter; | |
ai.threeD = false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DebugUtil | |
{ | |
public static void DumpRenderTexture(RenderTexture rt, string pngOutPath) | |
{ | |
var oldRT = RenderTexture.active; | |
var tex = new Texture2D(rt.width, rt.height); | |
RenderTexture.active = rt; | |
tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
namespace PvpGame | |
{ | |
public class GridValue | |
{ | |
public enum EntityType |