Skip to content

Instantly share code, notes, and snippets.

@grimmdev
grimmdev / CameraDragController.cs
Last active September 17, 2015 09:15
I made this myself, I wanted to give it a shot and I needed a simple yet customized solution for Camera Dragging.
using UnityEngine;
using System.Collections;
public class CameraDragController : MonoBehaviour {
public Transform Target;
public float Sensitivity = 0.1f;
public bool Invert = false;
public bool Hold = false;
public Rect Bounds;
@grimmdev
grimmdev / Messenger.cs
Created October 7, 2015 07:56
Helpful Utility for Games in Unity
using System;
using System.Linq;
public static class Messenger
{
public static void AddListener(string eventType, Action handler)
{
MessengerInternal.AddListener(eventType, handler);
}
public static void AddListener<TReturn>(string eventType, Func<TReturn> handler)
{
@grimmdev
grimmdev / ListExtensions.cs
Created November 2, 2015 04:18
List Extensions for Unity
using System;
using System.Collections.Generic;
using UnityEngine;
public static class ListExtensions
{
private static System.Random s_rand = new System.Random();
public static T RandomElement<T>(this List<T> source)
{
if (source.Count == 0)
@grimmdev
grimmdev / Conversation.cs
Last active November 2, 2015 06:41
Simple Dialogues and Conversations in Unity. 👥 💬
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
[Serializable]
public class Conversation
{
// The ID of the current Conversation.
@grimmdev
grimmdev / GUIManager.cs
Last active December 28, 2015 05:20
Scaling GUI In Unity OLDUI
// In most games I need a touch of OLD Unity GUI and for that I need a scaling GUI solution, most out there just don't seem to really work for me.
// So I made my own with a very simple method, most designs rely on a target device resolution, if you know what that is.
// It essentially means everytime I design something I design GUI for ONE resolution and so I want it to scale to every resolution.
// So first we define our design resolution.
// For the example we chose a common portrait resolution.
[SerializeField]
private Vector2 DesignResolution = new Vector2(480,800);
// Now we need our Scale variable to store the difference between the design resolution and new.
[SerializeField]
@grimmdev
grimmdev / first
Last active December 4, 2015 04:28
My replacement for SWGEMU bin for many tweaks
#!/bin/bash
#
# first - Required programs and packages install for swgemu development environment
#
# Author: Scurby <[email protected]>
# Edited: Grimmdev <[email protected]>
#
# Created: Dec 3 2015
#
# Changed -
@grimmdev
grimmdev / miniscriptexample1.txt
Last active January 7, 2016 05:16
miniscript example 1
// My Example
print("Let's fly!")
ship.reset
ship.x = 0
ship.y = 0
for a in range(0, 90, 1)
ship.rot = a
wait(1/180)
end for
for a in range(0,90,1)
@grimmdev
grimmdev / JSONExtras.cs
Created January 8, 2016 03:15
Extra and useful JSON Functions for SimpleJSON
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using SimpleJSON;
public class JSONExtras {
public int[] ToIntArray(string n) {
var j = JSON.Parse(n);
int[] a = new int[j.Count];
@grimmdev
grimmdev / PreferenceUtility.cs
Created February 23, 2016 08:30
Preferences Utility for Unity 3D and uLiveWallpaper
// Sean Loper
// 2016
// PreferenceUtility.cs
using UnityEngine;
using System.Globalization;
using LostPolygon.uLiveWallpaper;
public class PreferenceUtility
{
@grimmdev
grimmdev / ShortGUID.cs
Last active April 15, 2017 09:21
32 bits of goodness.
using System;
public class ShortGUID
{
private static Guid tmpGuid;
public static string NewGuid()
{
tmpGuid = Guid.NewGuid ();
return Convert.ToBase64String(tmpGuid.ToByteArray());