Skip to content

Instantly share code, notes, and snippets.

View paulhayes's full-sized avatar

Paul Hayes paulhayes

View GitHub Profile
@paulhayes
paulhayes / Logger.cs
Created May 17, 2018 14:56
Simple Logging System
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu]
public class Logger : ScriptableObject
{
public const int Verbose = (int)Levels.Verbose;
public const int Debug = (int)Levels.Debug;
public const int Info = (int)Levels.Info;
-Image: /Users/paulhayes/Downloads/test.png
+Image: /Users/paulhayes/Downloads/DdKJ6sAWAAE_bgX.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 512x512+0+0
- Resolution: 28.35x28.35
- Print size: 18.06x18.06
- Units: PixelsPerCentimeter
+ Units: Undefined
@paulhayes
paulhayes / remove_duplicate_files.py
Created March 3, 2018 14:59
Finds and removes duplicate files
#/usr/bin/python
import sys
import os
import hashlib
def chunk_reader(fobj, chunk_size=1024):
"""Generator that reads a file in chunks of bytes"""
while True:
chunk = fobj.read(chunk_size)
if not chunk:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SoundDelayRepeat : MonoBehaviour
{
private AudioSource audioSource;
private float lastPlay;
public float firstTimeDelay;
public float timeInbetweenSound;
@paulhayes
paulhayes / wrap.js
Last active December 9, 2017 20:18
Using modulo operating to wrap values in both positive and negative directions
Number.prototype.wrap = function(len){return ((this.valueOf()%len)+len)%len; }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class TriangleMesh {
public static Mesh Create(float scale){
Mesh triangle = new Mesh();
Vector3[] vertexes = new Vector3[3];
Vector2[] uv = new Vector2[3];
@paulhayes
paulhayes / BuildMenu.cs
Created July 24, 2017 12:22
Adds Server build options to menu
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
using System.Security.AccessControl;
using System.Collections.Generic;
public class BuildMenu {
[MenuItem("File/Build Linux Headerless")]
@paulhayes
paulhayes / AppArgs.cs
Created July 10, 2017 19:31
Simple tool for getting command line arguments given to build executable in Unity
using System;
public static class AppArgs {
public static T GetNamedArgument<T>(string key,T defaultValue) {
string[] args = Environment.GetCommandLineArgs();
int index = -1;
for(int i=0; i<args.Length-1; i++ ){
if( args[i] == key ){
index = i+1;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TeleportTarget : MonoBehaviour
{
public string button = "Fire1";
public Transform lookDirection;
public Transform target;
@paulhayes
paulhayes / CubemapToEquirectangularWizard.cs
Created July 3, 2017 12:06 — forked from Farfarer/CubemapToEquirectangularWizard.cs
Create dynamic equirectangular maps for Unity. These have the benefit that, as they're flat images, you can sample lower mips to get blurry reflections. The straight cubemap version (detailed here: http://www.farfarer.com/blog/2011/07/25/dynamic-ambient-lighting-in-unity/ ) will give you hard seams when you sample mips from the cubemap. Although…
// Wizard to convert a cubemap to an equirectangular cubemap.
// Put this into an /Editor folder
// Run it from Tools > Cubemap to Equirectangular Map
using UnityEditor;
using UnityEngine;
using System.IO;
class CubemapToEquirectangularWizard : ScriptableWizard {