Skip to content

Instantly share code, notes, and snippets.

View keenanwoodall's full-sized avatar
🛠️
Making stuff!

Keenan Woodall keenanwoodall

🛠️
Making stuff!
View GitHub Profile
@bzgeb
bzgeb / TriggerContainerEditor.cs
Created September 28, 2012 14:52
Example Drag & Drop area in a custom inspector for the Unity editor
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor (typeof(TriggerContainer))]
public class TriggerContainerEditor : Editor
{
private SerializedObject obj;
@Fonserbc
Fonserbc / Easing.cs
Last active August 27, 2024 23:41
Compact and simple easing functions for Unity
using UnityEngine;
/*
* Most functions taken from Tween.js - Licensed under the MIT license
* at https://github.com/sole/tween.js
* Quadratic.Bezier by @fonserbc - Licensed under WTFPL license
*/
public delegate float EasingFunction(float k);
public class Easing
@MattRix
MattRix / UnityEditorIcons.txt
Last active October 21, 2024 23:36
A list of all the built-in EdtiorGUI icons in Unity. Use EditorGUIUtility.IconContent([icon name]) to access them.
ScriptableObject Icon
_Popup
_Help
Clipboard
SocialNetworks.UDNOpen
SocialNetworks.Tweet
SocialNetworks.FacebookShare
SocialNetworks.LinkedInShare
SocialNetworks.UDNLogo
animationvisibilitytoggleoff
@nothke
nothke / Draw.cs
Last active January 20, 2024 06:58
///
/// Draw lines at runtime
/// by Nothke
/// unlicensed, aka do whatever you want with it
/// made during Stugan 2016 :)
/// ..(it's midnight, and Robbie clicks A LOT, LOUDLY!)
///
/// Important:
/// - Should be called in OnPostRender() (after everything else has been drawn)
/// therefore the script that calls it must be attached to the camera
@yorung
yorung / calculate_gerstner_wave_orientation.hlsl
Last active August 9, 2024 01:57
Calculate gerstner wave normal, binormal, and tangent by GPU Gems's method.
float3 CalcGerstnerWaveNormal(float3 P)
{
float3 normal = float3(0, 1, 0);
[unroll]
for (int i = 0; i < numWaves; i++)
{
Wave wave = waves[i];
float wi = 2 / wave.waveLength;
float WA = wi * wave.amplitude;
float phi = speed * wi;
@phi-lira
phi-lira / UniversalPipelineTemplateShader.shader
Last active November 10, 2024 05:01
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
@LotteMakesStuff
LotteMakesStuff / NativeMeshTest.cs
Created August 8, 2018 00:30
[NativeCollections] How to copy a regular .C# array into a NativeArray suuuuuper quick using memcpy. its about as fast as its ever gunna get!
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Mathematics;
using UnityEngine;
public class NativeMeshTest : MonoBehaviour
{
private NativeArray<float3> vertexBuffer;
private Vector3[] vertexArray;
@playatwork
playatwork / SimplexNoise3Node.cs
Last active October 26, 2020 17:08
Simplex noise custom node for Shader Graph
//
// Simplex noise custom node for Shader Graph
//
// Original work (webgl-noise) Copyright (C) 2011 Ashima Arts.
// Translation and modification was made by Keijiro Takahashi.
// Ported to Shader Graph by Sergio L. Valladares
//
// This shader is based on the webgl-noise GLSL shader. For further details
// of the original shader, please see the following description from the
// original source code.
@TheAllenChou
TheAllenChou / Seek.cs
Last active August 26, 2019 10:15
Value Seeking
// example of how to move a current value towards a target value at a constant speed
// without going over the target value
// formula is the same for vectors of any dimension
Vector3 Seek(Vector3 currentValue, Vector3 targetValue, float maxSpeed, float dt)
{
// delta/difference from current value to target value
Vector3 delta = targetValue - currentValue;
// don't take the square root of magnitude yet
// so we can potentially early out on degenerate case of currenvValue ~= targetValue
@FreyaHolmer
FreyaHolmer / LengthTable.cs
Created August 21, 2019 02:18
Béziér curve utility class for converting a t value to percentage of distance along the spline
using UnityEngine;
public class LengthTable {
public float[] distances;
int SmpCount => distances.Length;
float TotalLength => distances[SmpCount - 1];
public LengthTable( OrientedCubicBezier3D bezier, int precision = 16 ) {
distances = new float[precision];