Skip to content

Instantly share code, notes, and snippets.

@Abban
Created April 27, 2026 06:58
Show Gist options
  • Select an option

  • Save Abban/db2451e51a984dbb6361d08ad2e5ff24 to your computer and use it in GitHub Desktop.

Select an option

Save Abban/db2451e51a984dbb6361d08ad2e5ff24 to your computer and use it in GitHub Desktop.
Add spline mode shortcuts to the Unity editor. Alt-S to toggle Spline Mode, Ctrl-S to select the Create Spline Tool
using System;
using System.Linq;
using UnityEditor;
using UnityEditor.EditorTools;
using UnityEditor.Splines;
using UnityEngine.Splines;
namespace Editor
{
public class SplineShortcuts : UnityEditor.Editor
{
[MenuItem("Tools/Spline Mode &s")]
private static void SplineMode()
{
var spline = Selection.activeTransform.gameObject.GetComponent<ISplineContainer>();
if (spline == null) return;
if (ToolManager.activeContextType == typeof(SplineToolContext))
{
ToolManager.SetActiveContext<GameObjectToolContext>();
}
else
{
ToolManager.SetActiveContext<SplineToolContext>();
}
}
[MenuItem("Tools/Create Spline ^s")]
private static void CreateSpline()
{
// Use the assembly to get the type, because CreateSplineTool is internal and we cant do typeof(CreateSplineTool)
var assembly = AppDomain.CurrentDomain.GetAssemblies()
.SingleOrDefault(a => a.GetTypes().Any(t => t.Namespace == "UnityEditor.Splines"));
if (assembly == null) return;
var privateType = assembly.GetType("UnityEditor.Splines.CreateSplineTool", true);
ToolManager.SetActiveContext<SplineToolContext>();
ToolManager.SetActiveTool(privateType);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment