1. 隱藏原本的視窗外框
2. 在視窗內畫出客製作的視窗外框
這邊概述隱藏視窗外框的方法:
1. 編譯一個 DLL 檔(目的用來呼叫 WIN32 API),DLL 檔內提供一個隱藏視窗的函數 HideWindow() 如下:
int __declspec(dllexport) __stdcall HideWindow() { //finde window HWND hWin =GetActiveWindow(); if (hWin ==0) return 0; RECT rc; GetClientRect(hWin, &rc); long lStyle =GetWindowLong(hWin, GWL_STYLE); lStyle =lStyle & (~WS_CAPTION); SetWindowLong( hWin, GWL_STYLE, lStyle); SetWindowPos(hWin, NULL, 0, 0, rc.right, rc.bottom, SWP_NOMOVE); return 2; }2. 將編譯出來的 DLL 檔加至 Project 的 plugin 目錄下。
3. 在 Unity3D 裡建立一個 C# Script,並在裡面加入,其中 winframehidden 為 DLL 檔名:
[DllImport("winframehidden")] private static extern int HideWindow();
然後在 Start() 函數內呼叫 HideWindow() 即可。
大大您好,
回覆刪除請問我依照這的方式依序導入U3D中,卻沒有隱藏視窗的效果,
我用的版本是3.5 F2
測試腳本有進去,但是沒有反應,
請問這是甚麼問題呢?
Ray 您好~
刪除因為文章列出的步驟非常簡略,而最後執行時未能成功可能是其它未在文章中列出之設定的遺漏導致。
我把這部分的實作包含原始碼及執行檔放在 https://github.com/phardera/unity3d_hide_win_frame 供您參考,其中:
hide_win_frame_deploy : 是 unity build 的執行檔
hide_win_frame_dll : 是給 unity 使用的 dll plugin
hide_win_frame_unity : 是 unity project