Skip to content

Instantly share code, notes, and snippets.

View plyoung's full-sized avatar

Leslie Young plyoung

View GitHub Profile
@plyoung
plyoung / NodeExtensions.cs
Created July 1, 2026 10:54
Various extensions for Godot C#
using Godot;
using System.Collections.Generic;
using GodotTask;
namespace Game;
public static class NodeExtensions
{
private static Variant s_name = Variant.CreateFrom("name");
private static Variant s_signal = Variant.CreateFrom("signal");
@plyoung
plyoung / InputConfig.cs
Created April 19, 2026 07:17
Godot input binding UI example.
using Godot;
using System;
using System.Text;
using System.Collections.Generic;
namespace Game;
public class InputConfig
{
public event Action SettingsChanged;
@plyoung
plyoung / GameResourceLoader.cs
Created July 4, 2025 12:35
Loading resources async in Godot
#define JOBS_ENABLED
#define JOBS_IN_EDITOR
//#define ONE_JOB_AT_TIME
using Godot;
using System;
using System.Collections.Generic;
using Fractural.Tasks;
using ThreadLoadStatus = Godot.ResourceLoader.ThreadLoadStatus;
@plyoung
plyoung / GodotFormatters.cs
Created January 1, 2024 11:54
Godot + MessagePack-CSharp
// for using MessagePack-CSharp with Godot
// see: https://github.com/MessagePack-CSharp/MessagePack-CSharp
using System;
using System.Buffers;
using MessagePack;
using MessagePack.Formatters;
using Godot;
namespace MessagePack.Godot;
@plyoung
plyoung / AutoDismissPackagesWarning.cs
Last active December 9, 2022 11:04
Auto dismiss Unity's toolbar warning about using experimental packages
using System;
using System.Reflection;
using UnityEngine;
using UnityEditor;
namespace Game.Ed.Common
{
[InitializeOnLoad]
public static class AutoDismissPackagesWarning
{
@plyoung
plyoung / GameEdContent.cs
Last active May 4, 2019 08:07
Unity UIElements based editor window with  menu list.
using UnityEngine.UIElements;
namespace GameEditor
{
// base class for game editors shown in the game editor window
public class GameEdContent
{
// The label is shown in the menu list and is also used as a heading in the right pane
public virtual string Label { get; } = "Unknown";
@plyoung
plyoung / VerticalSplitter.cs
Last active April 24, 2018 12:54
A vertical splitter control in Unity
private static readonly int SplitterHash = "VerticalSplitterControl".GetHashCode();
/// <summary> Draw a splitter. Returns a delta of how far splitter was dragged during this frame. </summary>
public static float VerticalSplitter()
{
float delta = 0f;
Event ev = Event.current;
Rect r = GUILayoutUtility.GetRect(5f, 1f, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(false));
int id = GUIUtility.GetControlID(SplitterHash, FocusType.Passive, r);
@plyoung
plyoung / UnityEditorAutoGridSnap
Last active March 4, 2019 15:29
Toggle auto-snapping in Unity. It uses the snap settings you choose for Move X, Y, Z under menu: `Edit > Snap Settings`. Toggle it on/off via menu: `Edit > Toggle Auto-Snap` or Ctrl+L (Cmd+L). Add this code to an editor script. That is a script (file) created in a folder or sub-folder of one named `Editor` in your project.
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
public class UnityEditorAutoGridSnap
{
private static bool autoSnap = false;
private static Vector3 prevTrPos = Vector3.zero;
static UnityEditorAutoGridSnap()