Extending Studio

Turian Studio is a plugin for Gaya, a platform built to be extended. Your project's scripts can extend Studio too — with attributes, without referencing any editor assembly. Everything below is picked up when your scripts compile and refreshed on every recompile.

A public static method with [MenuItem] becomes a menu command. The first path segment picks the menu; File, Edit, View, Project and Help land in Studio's own menus, anything else creates a new one:

namespace Usercode;

public static class LevelTools
{
    [MenuItem("Tools/Count Scene Files")]
    public static void CountScenes() =>
        Log.Logger.LogInformation("{Count} scenes", Directory.GetFiles("Assets", "*.prefab", SearchOption.AllDirectories).Length);
}

The method takes no parameters, or one: an IServiceProvider, or any service Studio can resolve. Menu items also appear in the command palette, where you can give them a shortcut.

Panels

A plain class with [Panel] becomes a dockable panel. Its public members are drawn as a form, and [Button] methods as buttons:

namespace Usercode;

[Panel("Level Stats", "Tools/Level Stats")]
public sealed class LevelStatsPanel
{
    public string Note { get; set; } = "";
    public int Enemies { get; set; }

    [Button]
    public void Report() => Log.Logger.LogInformation("{Note}: {Enemies} enemies", Note, Enemies);
}

The second argument is the menu path that opens it (it defaults to Window/<name>).

Settings pages

A class with [EditorSetting] becomes a page in File → Settings…; its values are saved and restored:

[EditorSetting("My Tools/Level Export", Description = "How level files are exported.")]
public sealed class LevelExportSettings
{
    [EditorSetting("Compress", Description = "Write compressed level files.")]
    public bool Compress { get; set; } = true;

    public string OutputFolder { get; set; } = "Exports";
}

More extension points

Attribute Adds See
[CustomGizmo(drawer, component)] Scene view drawing for a component Gizmos
[AssetPreview(assetType)] Inspector previews for an asset type Asset Preview
[CreateAssetMenu(path)] A New entry in the Assets panel for a data asset Assets
[ComponentContextMenu(path)] The place of a component in Add Component Components
[Button], [Range], [ReadOnly], [HideInEditor], … How members look in the Inspector Components

Gaya plugins

Studio's panels, menus and commands are themselves contributions of a Gaya plugin (Gaya.Plugin.Turian). Writing a separate Gaya plugin — for tools that are not tied to one project — uses the same registries: panels, commands, menus, shortcuts, settings pages and themes.


← All docs Edit this page