当前位置:   article > 正文

unity发布设置(最小化、置顶、限制单开)_unity 窗口置顶

unity 窗口置顶

1. 勾上下图标红处,发布后可防止按windows键缩小

 2.发布后程序默认最小化

  1. using System;
  2. using System.Runtime.InteropServices;
  3. using UnityEngine;
  4. /// <summary>
  5. /// 开始时最小化窗口
  6. /// </summary>
  7. public class SetWindowMin : MonoBehaviour
  8. {
  9. [DllImport("user32.dll")]
  10. public static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
  11. [DllImport("user32.dll")]
  12. static extern IntPtr GetActiveWindow();
  13. const int SW_SHOWMINIMIZED = 2; //{最小化, 激活}
  14. const int SW_SHOWMAXIMIZED = 3;//最大化
  15. const int SW_SHOWRESTORE = 1;//还原
  16. private void Start()
  17. {
  18. ShowWindow(GetActiveWindow(), SW_SHOWMINIMIZED);
  19. }
  20. }

3.发布的程序只能开一个进程

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using UnityEngine;
  5. public class Process_sigle : MonoBehaviour
  6. {
  7. // Start is called before the first frame update
  8. void Start()
  9. {
  10. //检测是否打开
  11. Process[] app = Process.GetProcessesByName("Da_Ping_show");
  12. if (app.Length >1)
  13. {
  14. for (int i =1; i < app.Length; i++)
  15. {
  16. app[i].Kill();
  17. }
  18. return;
  19. }
  20. }
  21. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/48783
推荐阅读
相关标签
  

闽ICP备14008679号