Skip to content

Instantly share code, notes, and snippets.

@MizoTake
Created December 9, 2019 11:25
Show Gist options
  • Select an option

  • Save MizoTake/65a22e6721e996da64d66558bb0db022 to your computer and use it in GitHub Desktop.

Select an option

Save MizoTake/65a22e6721e996da64d66558bb0db022 to your computer and use it in GitHub Desktop.
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
namespace ChangeEditorColorFromPath
{
#if UNITY_EDITOR_WIN
[InitializeOnLoad]
public class ChangeEditorTitlebar
{
[DllImport("user32.dll")]
static extern IntPtr GetActiveWindow();
[DllImport("user32.dll", EntryPoint = "SetWindowText")]
static extern bool SetWindowText(System.IntPtr hwnd, System.String lpString);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int GetWindowTextLength(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
static ChangeEditorTitlebar()
{
var target = "Review";
var path = Application.dataPath;
var isMatch = Regex.IsMatch(path, target);
if (!isMatch) return;
var window = GetActiveWindow();
if (window == IntPtr.Zero) return;
var length = GetWindowTextLength(window);
var stringBuilder = new StringBuilder(length + 1);
GetWindowText(window, stringBuilder, stringBuilder.Capacity);
var titleBarText = stringBuilder.ToString();
SetWindowText(window, titleBarText + $" - {target}");
}
}
#endif
}
@MizoTake
Copy link
Author

MizoTake commented Dec 9, 2019

Change Title Bar Extension

UnityProjectが特定ディレクトリにあれば、TitleBarの文字列に検索対象のディレクトリ名を追加します

記事 → http://maketake.hatenablog.com/entry/advent-calendar/2019/unity/08

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment