我最终需要将游戏屏幕设置为最上面的(前景)窗口。
但是我的函数什么也没做(但是其他user32.dll函数也可以工作)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;
public class DatabaseManager : MonoBehaviour
{
//DLL imports
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
static Process proc = Process.GetProcessesByName("firefox")[0];
IntPtr ptrFF = proc.Handle;
//------------------------------------------------------------------------
void Awake()
{
SetForegroundWindow(ptrFF);
}
//Other code functions like Update etc.
}
什么也没有发生,没有错误。有没有办法将窗户强行推向前方