Skip to content

Developer API ​

The general-purpose classes used inside the package can also be used from outside.

ReflectionDelegateFactory ​

A factory that generates fast access delegates to Unity's internal APIs. It is based on Expression Trees and supports methods / property accessors (with automatic get_ / set_ fallback) / field reads and writes / constructor calls.

csharp
// インスタンスメソッド
var del = ReflectionDelegateFactory.Create<Action<object>>(
    "UnityEditor.Graphs.ParameterControllerView", "DeleteParameter");

// プロパティ getter
var getter = ReflectionDelegateFactory.Create<Func<object, AnimatorController>>(
    "UnityEditor.Graphs.IAnimatorControllerEditor", "animatorController");

// 静的メソッド (out 引数 OK)
public delegate bool TryGetFolderPathDelegate(out string path);
var f = ReflectionDelegateFactory.Create<TryGetFolderPathDelegate>(
    "UnityEditor.ProjectWindowUtil", "TryGetActiveFolderPath");

// フィールド getter / setter
var fg = ReflectionDelegateFactory.CreateFieldGetter<object>(
    "UnityEditor.Graphs.ParameterControllerView", "m_Host");
var fs = ReflectionDelegateFactory.CreateFieldSetter<int>(
    "UnityEditor.Graphs.LayerControllerView", "m_SelectedIndex");

// 引数なしコンストラクタ
var ctor = ReflectionDelegateFactory.CreateConstructor<Func<object>>(
    "UnityEditor.Graphs.LayerControllerView");
var instance = ctor();

When a member is not found

If the member cannot be found, Create<TDelegate> reports Member not found: <member> in <class> via LogError. This gives you a clue when investigating a delegate that suddenly became null because of a Unity version difference.

Generated delegates are not cached

When used in a hot path (such as every frame), cache the generated delegate on the caller side. Not supported: instantiating generic methods, out / ref arguments on instance methods (static methods are supported), and explicit selection when a void method and a setter with the same name collide.

New Hierarchy Column Registration API ​

You can add custom columns to the New Hierarchy Window with the [SCEHierarchyColumn] attribute.

Extension Methods ​

ClassMain uses
AnimatorExtensionsGetAllStates / GetAllStatePairs / GetAllTransitions / AddLayerEx / PasteLayer / CloneObject
ColorExtensionsHex → Color conversion (HexToColor)
ComponentExtensionsComponent reference check (IsComponentReferenced)
EditorWindowExtensionsGetDockAreaWindows / RepaintEditor / extended GetWindow
GameObjectExtensionsBatch retrieval of descendant components
GUIExtensionsToggleSafe / SliderSafe / Foldout / DrawHorizontalLine
ModularAvatarExtensionsGetParameterInfos / GetParameterBits
PathUtilsAbsolute path ↔ Asset path conversion

Other Useful Classes ​

  • InputKeyChecker — Global key input events inside the Unity Editor
  • ComponentPropertyWindowOpener — Opens any component in its own floating property window
  • SearchComponentDropdown — Hierarchical component search UI based on the AddComponentMenu attribute
  • CallerUtils — Gets the caller's Type

MIT License