Skip to content

Instantly share code, notes, and snippets.

@Nordaj
Nordaj / RenderCamera.cs
Last active June 18, 2017 22:26
With this Unity editor script you can render the camera to an image at any resolution in engine. Should auto fill to be quick and easy. Just throw this in a folder named "Editor" under any directory in the project. To use go to Window/Render Camera. Enjoy
using System;
using System.IO;
using UnityEngine;
using UnityEditor;
public class RenderCamera : EditorWindow
{
//Private Variables
private Camera cam;
private Vector2 size;
@Nordaj
Nordaj / Snake.cs
Created December 31, 2017 01:17
Unity editor script simple snake game
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class Snake : EditorWindow
{
//Settings
int unit = 25;
Color headCol = new Color(0, 0.5f, 1);
Color tailCol = new Color(0, 0.5f, 0.8f);
@Nordaj
Nordaj / CamShake.cs
Created March 11, 2018 08:07
Simple camera shake script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CamShake : MonoBehaviour
{
//Public Variables
[Header("Call 'Shake()' to shake")]
[Range(0, 2)]
public float intensity = 0.2f;
@Nordaj
Nordaj / Joystick.cs
Last active April 10, 2018 02:20
Simple joystick script for mobile use. Dynamic position joystick and has a public member "value"(v2) to store the input value. To use: Create image for the outer circle as a UI object. Create child image for the inner circle. Slap the script on your parent image and you're good to go.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Joystick : MonoBehaviour
{
//Public Variables
public Image centerImg;
[Tooltip("This field does not need to be filled")]
@Nordaj
Nordaj / DataManager.cs
Last active September 16, 2018 15:06
Use this unity script to save and load data. It will work with any serializable type.
using System;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public static class DataManager
{
private static Dictionary<string, object> data;
/// <summary>
@Nordaj
Nordaj / Keys.h
Last active June 13, 2024 17:42
Windows API VK key codes as an enum and easier names with comments for every key. (Aligns correctly with tab size 4)
#pragma once
enum class Key
{
LeftMouseBtn =0x01, //Left mouse button
RightMouseBtn =0x02, //Right mouse button
CtrlBrkPrcs =0x03, //Control-break processing
MidMouseBtn =0x04, //Middle mouse button
ThumbForward =0x05, //Thumb button back on mouse aka X1
@Nordaj
Nordaj / LinkedList.h
Last active November 13, 2018 00:28
Singly linked list in c
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
#include <stdlib.h>
#include <stddef.h>
typedef struct LLNode
{
void *data;
struct LLNode *next;
@Nordaj
Nordaj / DynamicArray.h
Created November 13, 2018 00:28
Dynamic array in c
#ifndef DYNAMIC_ARRAY_H
#define DYNAMIC_ARRAY_H
#include <stdlib.h>
#include <stddef.h>
#define DYNAMIC_ARRAY_INIT_CAPACITY 4
#define DYNAMIC_ARRAY_GROWTH_FACTOR 2
typedef struct List
@Nordaj
Nordaj / Stack.h
Created November 17, 2018 07:44
Stack implementation header only in c
#ifndef STACK_H
#define STACK_H
#include <stdlib.h>
#include <stddef.h>
#define DYNAMIC_ARRAY_INIT_CAPACITY 4
#define DYNAMIC_ARRAY_GROWTH_FACTOR 2
typedef struct Stack
@Nordaj
Nordaj / Deformable.cs
Created May 16, 2019 01:03
Runtime mesh deformation on impact script for Unity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Deformable : MonoBehaviour
{
//Public
public float minImpulse = 2;
public float malleability = 0.05f;
public float radius = 0.1f;