Created
December 9, 2019 11:25
-
-
Save MizoTake/65a22e6721e996da64d66558bb0db022 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change Title Bar Extension
UnityProjectが特定ディレクトリにあれば、TitleBarの文字列に検索対象のディレクトリ名を追加します
記事 → http://maketake.hatenablog.com/entry/advent-calendar/2019/unity/08
参考