Skip to content

Instantly share code, notes, and snippets.

@grimmdev
grimmdev / ArrayHelper.cs
Created August 24, 2015 07:50
I made this to help with dealing in Arrays!
using System;
using UnityEngine;
public static class ArrayHelper
{
public static T AddArrayElement<T>(ref T[] array) where T : new()
{
return ArrayHelper.AddArrayElement<T>(ref array, (default(T) == null) ? Activator.CreateInstance<T>() : default(T));
}
@grimmdev
grimmdev / AlphaAnimator.cs
Created August 24, 2015 07:44
Animates the Alpha on a Renderer
using System;
using UnityEngine;
[ExecuteInEditMode]
public class AlphaAnimator : MonoBehaviour
{
[Range(0f, 1f), SerializeField]
private float m_alpha;
private Renderer m_renderer;
private MaterialPropertyBlock m_propBlock;
@grimmdev
grimmdev / Logger.cs
Created August 24, 2015 06:38
Made a Debug Logger Class for managing important Information!
using System;
using UnityEngine;
public class Logger {
private static string CUSTOM_MESSAGE = "CUSTOM LOGS: ";
private static bool PrintLog()
{
return true;
}
@grimmdev
grimmdev / QT_Trigger.cs
Last active November 2, 2019 18:52
Quick-Time Events for Unity, I made this with just a small amount of time, I plan to expand it but I wanted to give an example of how a QuickTime Event would work, as I'm building mine around my own solution and project. This also works for multiple Quick-Time Events.
using System.Collections;
using System.Collections.Generic;
// using this for Text Demonstration
using UnityEngine.UI;
public class QT_Trigger : MonoBehaviour {
// We could probably gut the Done State but I use it for my purpose.
public enum QTState { Ready, Delay, Ongoing, Done };
public QTState qtState = QTState.Ready;
// an enum for a possible response!
@grimmdev
grimmdev / SocketClient.cs
Last active August 29, 2015 14:25
WebSocket Client/Server in Unity using Websocket-Sharp, read the comments below to get started!
using System;
using UnityEngine;
using WebSocketSharp;
using System.Collections;
public class SocketClient : MonoBehaviour {
// Public Variables
public string ConnectionString = "ws://echo.websocket.org";
public string Message = "Hello World!";
@grimmdev
grimmdev / TextureFlip.cs
Last active April 11, 2022 14:52
Texture Invert-er for Unity converted to C#, Original from GirlsCanCode! https://girlscancode.wordpress.com/2015/03/02/unity3d-flipping-a-texture/
// Converted to C#, originally from https://girlscancode.wordpress.com/2015/03/02/unity3d-flipping-a-texture/
Texture2D FlipText(Texture2D original)
{
// We create a new texture so we don't change the old one!
Texture2D flip = new Texture2D(original.width,original.height);
// These for loops are for running through each individual pixel and then replacing them in the new texture.
for(int i=0; i < flip.width; i++) {
for(int j=0; j < flip.height; j++) {
flip.SetPixel(flip.width-i-1, j, original.GetPixel(i,j));
@grimmdev
grimmdev / Curved.shader
Created July 17, 2015 05:32
Subway Surfer like Curved World Shader for Unity
Shader "Custom/Curved" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_QOffset ("Offset", Vector) = (0,0,0,0)
_Dist ("Distance", Float) = 100.0
}
SubShader {
Tags { "RenderType"="Opaque" }
Pass
{
@grimmdev
grimmdev / DialoguePowerUI.cs
Created July 16, 2015 05:11
Custom PowerUI Live HTML with a small mod/edit to add support for NodeCanvas's Dialogue Trees.
using UnityEngine;
using System.Collections;
using PowerUI;
using NodeCanvas.DialogueTrees;
public class DialoguePowerUI : UnityEngine.MonoBehaviour {
public TextAsset HtmlFile;
#if UNITY_EDITOR
private LiveHtml Reloader;
@grimmdev
grimmdev / MoveController.cs
Created July 16, 2015 01:21
Pokemon Move Controller in Unity 3d with 2D!
// Sean Loper
// 2015
// Also supports complete controller input!
// Pokemon Styled Movement Controller for Unity of course!
using UnityEngine;
using System.Collections;
public class MoveController : MonoBehaviour {
@grimmdev
grimmdev / GUIManager.cs
Last active August 29, 2015 14:24
I modified the default PowerUI Manager to accept a design resolution, so you can design for one resolution that better fits all.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using PowerUI;
/// <summary>
/// This is the default PowerUIManager with a much needed design resolution.
/// </summary>
public class GUIManager : MonoBehaviour {