Skip to content

Instantly share code, notes, and snippets.

@N-Carter
N-Carter / Triangulator.cs
Created December 22, 2014 22:59
Triangulator
// Author: runevision
// URL: http://wiki.unity3d.com/index.php?title=Triangulator
// Version: http://wiki.unity3d.com/index.php?title=Triangulator&oldid=14208
//
// Then modified a bit. -NC
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
@N-Carter
N-Carter / FontEditor.cs
Created February 1, 2015 18:29
Custom editor for Unity Font objects.
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(Font))]
public class FontEditor : Editor
{
Font m_Font;
static bool m_TilingControlsVisible;
@N-Carter
N-Carter / OutlineMesh.cs
Created August 3, 2015 19:48
Experimental code to draw an convex outline around a mesh.
/*
** OutlineMesh.cs
*/
//#define DEBUG
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
@N-Carter
N-Carter / TerrainGenerator.cs
Created August 29, 2016 12:10
A simple terrain generator for Unity. The noise function comes from here: https://code.google.com/p/simplexnoise/source/browse/trunk/SimplexNoise/Noise.cs
using UnityEngine;
using System.Collections;
using System.Threading;
using SimplexNoise;
public class TerrainGenerator : MonoBehaviour
{
[SerializeField] protected int m_Size = 512; // TODO: Require PoT sizes
[SerializeField] protected float m_Height = 32.0f;
@N-Carter
N-Carter / EditorGUITools.cs
Created February 6, 2017 20:06
EditorGUITools
using UnityEngine;
using UnityEditor;
using System.Collections;
public class EditorGUITools : GUITools
{
public static void DrawOutlineRect(Rect rect)
{
DrawHorizontalLine(new Vector2(rect.x, rect.y), rect.width);
DrawVerticalLine(new Vector2(rect.x, rect.y), rect.height);
@N-Carter
N-Carter / grid_focus_connector.gd
Created December 20, 2021 13:02
Focus Connecting script for Godot's GridContainer
extends GridContainer
export var connect_on_ready : bool
func _ready() -> void:
if connect_on_ready:
connect_children()
extends KinematicBody2D
export(float) var speed := 8.0
export(float) var jump_impulse := 200.0
export(float) var max_speed := 200.0
export(float) var gravity_multiplier := 1.0
export(float) var snap_length := 5.0
export(float) var floor_damping := 200.0
@N-Carter
N-Carter / inventory_panel.gd
Created May 27, 2022 16:14
Inventory from Depths
class_name InventoryPanel
extends PopupDialog
export var item_slot_scene : PackedScene
export var scroll : NodePath
onready var scroll_node : ScrollContainer = get_node(scroll)
export var grid : NodePath
@N-Carter
N-Carter / pickup.gd
Created May 27, 2022 16:15
Pickup from Depths
class_name Pickup
extends RigidBody2D
export(Globals.PickupType) var type : int setget , get_type
export var sprite : NodePath
onready var sprite_node : AnimatedSprite = get_node(sprite) setget , get_sprite
# These should be translated strings, but let's keep it simple for now:
@N-Carter
N-Carter / palette_remap.gdshader
Last active August 8, 2023 11:46
A Godot shader which reads the lowest four bits from the input's blue channel and uses them to pick a substitute colour from a palette texture.
// Reads the lowest four bits from the input's blue channel and uses them to
// pick a substitute colour from a palette texture.
//
// The palette texture should be 16 pixels wide and 1 pixel high, with the
// colours arranged with index 0 at the left and index 15 at the right.
shader_type canvas_item;
render_mode blend_disabled, unshaded, skip_vertex_transform;
uniform sampler2D palette;