Skip to content

Instantly share code, notes, and snippets.

@grimmdev
grimmdev / HSBColor.cs
Created July 4, 2015 06:16
HSB Color for Unity 3D!
using System;
using UnityEngine;
[Serializable]
public struct HSBColor
{
public float H;
public float S;
public float B;
public float A;
@grimmdev
grimmdev / AnimatedGifDrawer.cs
Created June 23, 2015 01:12
Play Gifs in Unity 3D using System Drawing
/*
Copy the "System.Drawing.dll" file in the "*\Unity\Editor\Data\Mono\lib\mono\2.0" folder into your "Assets" folder.
2) Attach this script to any object in your scene.
3) Change the "loadingGifPath" field of the script, (in the Inspector view), to the path of your Gif file. (this can be relative, from the root project folder (i.e. the parent of the "Assets" folder), or absolute
*/
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using UnityEngine;
@grimmdev
grimmdev / Translate.cs
Last active January 31, 2025 18:25
Translate method/api using Unity 3D. Completely Free with no Restrictions, by using Google's Internal API, we cut out the need for any api keys.
// We need this for parsing the JSON, unless you use an alternative.
// You will need SimpleJSON if you don't use alternatives.
// It can be gotten hither. http://wiki.unity3d.com/index.php/SimpleJSON
using SimpleJSON;
using UnityEngine;
using System.Collections;
public class Translate : MonoBehaviour {
// Should we debug?
#pragma strict
import System;
var start : DateTime;
var stop : DateTime;
var repetitions : int = 5000000;
function Start () {
start = DateTime.Now;
@grimmdev
grimmdev / ServerScripter.js
Last active August 29, 2015 14:21
Server Side Scripting (JS Only)
#pragma strict
var url = "url to script";
function Start () {
// Start a download of the given URL
var www : WWW = new WWW (url);
// Wait for download to complete
yield www;
@grimmdev
grimmdev / TextureTest.cs
Created May 16, 2015 03:42
Small Texture Utility for some texture functions in Unity
using UnityEngine;
using System.Collections;
public class TextureTest : MonoBehaviour {
public Renderer rend;
// Use this for initialization
private void Awake () {
rend.material.mainTexture = TextureUtility.CamToText ();
@grimmdev
grimmdev / ActionTest.cs
Last active August 29, 2015 14:21
Using the Action Delegate and it's pretty sweet!
using UnityEngine;
using System;
using System.Collections;
public class ActionTest : MonoBehaviour {
// Use this for initialization
private void Awake () {
string url = "http://google.com";
StartCoroutine(WaitForRequest(url,(status)=>{
@grimmdev
grimmdev / Share.cs
Created May 15, 2015 21:07
Simple social network sharing class for any platform.
using UnityEngine;
using System.Collections;
public class Share {
public static void Facebook (string url)
{
Application.OpenURL ("https://www.facebook.com/sharer/sharer.php?u=" + url);
}
@grimmdev
grimmdev / ExampleManager.cs
Last active August 29, 2015 14:21
MonoBehaviourUtility for shared instances. The beauty of Singletons.
using UnityEngine;
using System.Collections;
public class ExampleManager : MonoBehaviour
{
static public ExampleManager sharedManager
{
get
{
return MonoBehaviourUtility.GetManager<ExampleManager>( ref _sharedManager );
@grimmdev
grimmdev / SiteLock.cs
Created May 14, 2015 03:18
Sitelock Unity3D Web Player
// You'll have to call these functions atleast once, on load of the game just to ensure your work isn't being stolen.
using UnityEngine;
using System.Collections;
public class SiteLock {
public static void WWWLock (string Domain) {
Application.ExternalEval("if(document.location.host != '" + Domain + "') { document.location='" + Domain + "'; }");
}