Created
December 9, 2019 18:17
-
-
Save mao-test-h/1ee30037da1879825a855bcf257e2b6f to your computer and use it in GitHub Desktop.
Unityのタイトルバーを「もなふわすい~とる~む」に設定出来るEditor拡張(Windows限定)
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
#if UNITY_EDITOR_WIN | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Text; | |
using UnityEditor; | |
namespace MonafuwaUtility | |
{ | |
static class MonafuwaSweetRoomEditor | |
{ | |
[DllImport("user32.dll")] | |
static extern IntPtr GetActiveWindow(); | |
[DllImport("user32.dll", EntryPoint = "SetWindowText", CharSet=CharSet.Unicode)] | |
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); | |
// refered to: | |
// - http://maketake.hatenablog.com/entry/advent-calendar/2019/unity/08 | |
[MenuItem("もなふわゆ~てぃりてぃ/Set Title")] | |
static void SetTitle() | |
{ | |
var window = GetActiveWindow(); | |
if (window == IntPtr.Zero) return; | |
var length = GetWindowTextLength(window); | |
var stringBuilder = new StringBuilder(length + 1); | |
GetWindowText(window, stringBuilder, stringBuilder.Capacity); | |
SetWindowText(window, "もなふわすい~とる~む"); | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment