いつもお世話になっております。
Unity で タイトルバーを非表示にする スクリプトを実装したところ、
タイトルバーの高さが短くなったものの、完全に消えきることが出来ません。
詳しい方いられましたら、ご教示頂けますと幸いです。
###実装したいこと
exeで
・タイトルバーの非表示
・位置をディスプレイの左上端にする
###実装スクリプト
こちらのスクリプトを引っ張ってきました。
https://qiita.com/gatosyocora/items/b9bc12b4d56ac763e8c0
http://tvmllab.com/unity%E3%81%A7dll%E3%82%92%E4%BD%BF%E3%81%86/
①WindowsControl.cs
C#
1using UnityEngine; 2using System.Collections; 3 4using System; 5using System.Runtime.InteropServices; 6 7namespace Utils { 8 9 // ここからコードを拝借させてもらいました! 10 // http://answers.unity3d.com/questions/13523/is-there-a-way-to-set-the-position-of-a-standalone.html 11 // http://stackoverflow.com/questions/2825528/removing-the-title-bar-of-external-application-using-c-sharp 12 13 /* 14 * 注意点! 15 * 実行するアプリケーションはfullscreenではなく、windowedの状態にしておく必要がある。 16 */ 17 public class WindowControl : MonoBehaviour { 18 19 [SerializeField] string windowName = "demo"; 20 [SerializeField] int x = 0; 21 [SerializeField] int y = 0; 22 [SerializeField] int width = 1920; 23 [SerializeField] int height = 1080; 24 [SerializeField] bool hideTitleBar = true; 25 26 [DllImport("user32.dll", EntryPoint = "SetWindowPos")] 27 private static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags); 28 29 [DllImport("user32.dll", EntryPoint = "FindWindow")] 30 public static extern IntPtr FindWindow(System.String className, System.String windowName); 31 32 // Sets window attributes 33 [DllImport("user32.dll")] 34 public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); 35 36 // Gets window attributes 37 [DllImport("user32.dll")] 38 public static extern int GetWindowLong(IntPtr hWnd, int nIndex); 39 40 // assorted constants needed 41 public static int GWL_STYLE = -16; 42 public static int WS_CHILD = 0x40000000; //child window 43 public static int WS_BORDER = 0x00800000; //window with border 44 public static int WS_DLGFRAME = 0x00400000; //window with double border but no title 45 public static int WS_CAPTION = WS_BORDER | WS_DLGFRAME; //window with a title bar 46 47 void Awake () { 48 var window = FindWindow(null, windowName); 49 if(hideTitleBar) { 50 int style = GetWindowLong(window, GWL_STYLE); 51 SetWindowLong(window, GWL_STYLE, (style & ~WS_CAPTION)); 52 } 53 SetWindowPos(window, 0, x, y, width, height, width * height == 0 ? 1 : 0); 54 } 55 56 } 57 58}
②user32.dll を Pluginsフォルダにおく
C#
1extern "C" __declspec(dllexport) int Add(int a, int b) 2{ 3 return(a + b); 4}
###現在起きている状況
上図のように、タイトルバーが少し残ってしまいます。
何卒宜しくお願い致します。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/22 02:38