强制 Unity 编辑器更新其窗口标题。此函数在加载新场景或编辑器启动时自动调用。已在 EditorApplication.updateMainWindowTitle 上注册回调的用户可以调用此函数来强制更新标题。
using UnityEditor; using UnityEngine; public class WindowTitleExample { private static void CustomTitleBar(ApplicationTitleDescriptor desc) { desc.title = $"My Editor Custom Title version: {Random.value}"; } [MenuItem("Test/Setup custom title bar")] static void Setup() { EditorApplication.updateMainWindowTitle -= CustomTitleBar; // This callback will be triggered when a new scene is loaded or when Unity starts. EditorApplication.updateMainWindowTitle += CustomTitleBar; EditorApplication.UpdateMainWindowTitle(); } }