提交日志-20240704-2040:

1、启动后窗口置顶
This commit is contained in:
Afeijia 2024-07-04 20:40:08 +08:00
parent c340de5e04
commit d10f8146db
1 changed files with 31 additions and 20 deletions

View File

@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.SceneManagement;
@ -36,6 +37,12 @@ public class CallForTest : MonoBehaviour
/// </summary>
public string ServerIP;
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern IntPtr SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint wFlags);
const uint SWP_SHOWWINDOW = 0x0040;
const int HWND_TOPMOST = -1;
private void Awake()
{
instance = this;
@ -46,6 +53,10 @@ public class CallForTest : MonoBehaviour
//#else
// Debug.unityLogger.logEnabled = false;
//#endif
Debug.Log(Application.productName);
IntPtr ptr = FindWindow(null, Application.productName);
SetWindowPos(ptr, (IntPtr)HWND_TOPMOST, 0, 0, Screen.width, Screen.height, SWP_SHOWWINDOW);
}
private void OnGUI()