Skip to content

Instantly share code, notes, and snippets.

@TheAllenChou
TheAllenChou / Seek.cs
Last active February 2, 2025 16:22
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
@LotteMakesStuff
LotteMakesStuff / AutohookAttribute.cs
Last active September 29, 2025 17:12
[Autohook] property drawer for unity - Add this [Autohook] attribute to a property to and the inspector will automagically hook up a valid reference for you if it can find a component attached to the same game object that matches the field you put it on. You can watch a demo of this in action here https://youtu.be/faVt09NGzws <3
// NOTE DONT put in an editor folder!
using UnityEngine;
public class AutohookAttribute : PropertyAttribute
{
}
@bitinn
bitinn / .a-unity-git-config.md
Last active April 2, 2025 07:53
My Unity git config
@GhatSmith
GhatSmith / OpenAdditionalLockedInpsector.cs
Created November 27, 2018 17:45
Little script to open a locked inspector window as popup in Unity
using UnityEditor;
using UnityEngine;
using System.Reflection;
namespace Framework.Core.EditorExtension
{
public class OpenAdditionalLockedInpsector : MonoBehaviour
{
private static EditorWindow lockedInspectorWindow = null;
@GhatSmith
GhatSmith / OpenAdditionalAnimatorWindow.cs
Created November 27, 2018 17:28
Little script to open an additional Animator window in Unity
using UnityEditor;
using UnityEngine;
namespace Framework.Core.EditorExtension
{
public class OpenAdditionalAnimatorWindow : MonoBehaviour
{
static EditorWindow window = null;
@rngtm
rngtm / GradientToPng
Created November 19, 2018 15:01
UnityのGradient(グラデーション)を256x1のpngとして書き出すエディター拡張。
using UnityEngine;
using UnityEditor;
using System.IO;
public class GradientToPng : EditorWindow
{
[SerializeField]
private Gradient m_Gradient;
[MenuItem("Tools/Gradient To Png")]
@MBoffin
MBoffin / FlatUI.colors
Created November 7, 2018 19:54
The Flat UI Palette v1 from flatuicolors.com
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 52
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 1
@MBoffin
MBoffin / PICO-8.colors
Created November 7, 2018 19:48
PICO-8 Color Palette for Unity Projects
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 52
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 1
@jackpr-unity
jackpr-unity / LegacyButtonsAndAxes.preset
Created September 7, 2018 16:34
This preset file can be imported to the Unity Input Manager. It exposes the 20 buttons and 28 axes that are available in the Unity Input Manager as of Unity editor 2018.3
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!181963792 &2655988077585873504
Preset:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: LegacyButtonsAndAxes
m_TargetType:
/// For this to work you need to copy these 2 files:
/// "YOUR UNITY LOCATION"\Editor\Data\Mono\lib\mono\X.X\System.Drawing.dll
/// "YOUR UNITY LOCATION"\Editor\Data\Mono\lib\mono\X.X\System.Windows.Forms.dll
/// ..to a "Plugins" folder within your project
///
/// For this example to work, you need to have a (UI) Canvas object in your scene
/// Put this script on any object
///
/// Tested on windows, not sure if it works on any other platform
///