Skip to content

Instantly share code, notes, and snippets.

View nukadelic's full-sized avatar
☣️

Nukadelic nukadelic

☣️
View GitHub Profile
@gre
gre / easing.js
Last active April 30, 2024 04:58
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Last active April 30, 2024 08:05
Unity extension methods for computing a ConfigurableJoint.TargetRotation value from a given local or world rotation.
using UnityEngine;
public static class ConfigurableJointExtensions {
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
if (joint.configuredInWorldSpace) {
@MattRix
MattRix / MonoBehaviourInspector
Last active October 12, 2021 02:51
Allows you to use OnInspectorGUI in MonoBehaviour directly, rather than having to create a CustomEditor
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
[CustomEditor (typeof(MonoBehaviour),true)]
[CanEditMultipleObjects]
public class MonoBehaviourInspector : Editor
{
@Arakade
Arakade / gist:9dd844c2f9c10e97e3d0
Created January 3, 2015 16:54
Call from OnDrawGizmos() to draw text at Unity3D glocal position in Editor
static void drawString(string text, Vector3 worldPos, Color? colour = null) {
UnityEditor.Handles.BeginGUI();
if (colour.HasValue) GUI.color = colour.Value;
var view = UnityEditor.SceneView.currentDrawingSceneView;
Vector3 screenPos = view.camera.WorldToScreenPoint(worldPos);
Vector2 size = GUI.skin.label.CalcSize(new GUIContent(text));
GUI.Label(new Rect(screenPos.x - (size.x / 2), -screenPos.y + view.position.height + 4, size.x, size.y), text);
UnityEditor.Handles.EndGUI();
}
@mattatz
mattatz / LIC.shader
Last active April 3, 2022 14:09
Simple Line Integral Convolution shader for Unity.
Shader "Mattaz/LIC" {
Properties {
_VectorFieldTex ("Vector Field Texture", 2D) = "white" {}
_NoiseTex ("Noise Texture", 2D) = "white" {}
_FlowLength ("Flow Length", int) = 10
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
@MattRix
MattRix / IsoSurface.cs
Last active October 12, 2021 02:48
Quick and dirty marching tetraheda isosurface thing
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
[RequireComponent (typeof(MeshRenderer))]
[RequireComponent (typeof(MeshFilter))]
public class IsoSurface : MonoBehaviour
{
@v01pe
v01pe / Example.cs
Last active November 14, 2022 18:03
A relative simple way to get the instance object from a custom property drawer that draws a serialized class inside a component
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
public ExampleClass example;
void Start() {}
void Update() {}
}
@MattRix
MattRix / PhysicsFollower.cs
Last active October 1, 2023 03:22
A thing you can use to make a rigidbody move towards a position reliably
using UnityEngine;
using System.Collections;
using System;
[RequireComponent (typeof(Rigidbody))]
public class PhysicsFollower : MonoBehaviour
{
public Transform target;
Rigidbody rb;
@tomkail
tomkail / ExtendedScriptableObjectDrawer.cs
Last active April 2, 2024 18:56
Displays the fields of a ScriptableObject in the inspector
// Developed by Tom Kail at Inkle
// Released under the MIT Licence as held at https://opensource.org/licenses/MIT
// Must be placed within a folder named "Editor"
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
@solkar
solkar / BakeStaticCubemap.cs
Created July 17, 2017 13:24
Bake into Cubemap Unity Editor Script
/*
* This confidential and proprietary software may be used only as
* authorised by a licensing agreement from ARM Limited
* (C) COPYRIGHT 2014 ARM Limited
* ALL RIGHTS RESERVED
* The entire notice above must be reproduced on all authorised
* copies and copies may only be made to the extent permitted
* by a licensing agreement from ARM Limited.
*/