Skip to content

Instantly share code, notes, and snippets.

View grimmdev's full-sized avatar

Sean Loper grimmdev

View GitHub Profile
@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 / 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 / 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 <scurby@swgemu.com>
# Edited: Grimmdev <grimmdev@gmail.com>
#
# Created: Dec 3 2015
#
# Changed -
@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 / 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 / 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 / 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 / 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 / DroidScriptFunctions.js
Created September 1, 2015 02:55
DroidScript/Javascript Functions
String.format = function() {
// The string containing the format items (e.g. "{0}")
// will and always has to be the first argument.
var theString = arguments[0];
// start with the second argument (i = 1)
for (var i = 1; i < arguments.length; i++) {
// "gm" = RegEx options for Global search (more than one instance)
// and for Multiline search
var regEx = new RegExp("\\{" + (i - 1) + "\\}", "gm");
@grimmdev
grimmdev / AdditiveProtocol.cs
Last active August 31, 2015 10:24
Custom PowerUI Protocols for Unity3D for some savory and simple functions.
using PowerUI.Css;
using UnityEngine;
namespace PowerUI{
/// <summary>
/// This additive:// protocol enables a link to point to another scene.
/// E.g. href="additive://sceneName" will load the scene additive called 'sceneName' when clicked.
/// </summary>