Skip to content

Instantly share code, notes, and snippets.

@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 / 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>
@grimmdev
grimmdev / GameObjectExtension.cs
Created August 24, 2015 08:18
Some useful functions that extends Unity's GameObject
using System;
using System.Collections.Generic;
using UnityEngine;
public static class GameObjectExtension
{
public static T GetComponentInParents<T>(this Component self) where T : Component
{
return self.transform.GetComponentInParents<T>();
}
@grimmdev
grimmdev / FPSCounter.cs
Created August 24, 2015 08:13
Crack at my own FPS Counter
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FPSCounter : MonoBehaviour
{
[SerializeField]
public Text m_label;