当前位置: 首页 > news >正文

Unity 创建快捷方式开机自动启动

Unity 创建快捷方式自动启动

  • 🌭食用方法

🌭食用方法

先导入插件包👈,再 把导入的ZYF_AutoRunApp.cs 挂到物体上即可。

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace ZYF
{public class ZYF_AutoRunApp : MonoBehaviour{private static string ShortcutName = "zyf.lnk";private void OnEnable(){//Debug.Log(Environment.GetFolderPath(Environment.SpecialFolder.Startup));if (IsStartup() == false && Application.isEditor == false){ShortcutName = $"{Application.productName}.lnk";SetupStartup(exePath: System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName,shortCutName: ShortcutName);}}public static  void SetupStartup(string exePath ,string shortCutName="xxx.lnk"){CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Startup),shortCutName,targetPath:exePath);}private bool IsStartup(){return System.IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + ShortcutName);}public static bool CreateShortcut(string directory, string shortcurName, string targetPath, string description = null, string iconLocation = null){try{if (!Directory.Exists(directory)){Directory.CreateDirectory(directory);}....return true;}catch{}return false;}private static void DeleteOldShortcut(string shortscurPath){if (System.IO.File.Exists(shortscurPath)) { System.IO.File.Delete(shortscurPath);Debug.Log($"删除旧的:{shortscurPath}");}}}
}
http://www.lryc.cn/news/321473.html

相关文章:

  • 什么是docker(docker客户端、镜像、容器、仓库)
  • [Python人工智能] 四十三.命名实体识别 (4)利用bert4keras构建Bert+BiLSTM-CRF实体识别模型
  • Android Framework开发之Linux +Vim命令
  • MySQL 索引的10 个核心要点
  • MaixSense-A010 接入 ROS
  • 使用WordPress在US Domain Center上建立招聘网站的详细教程
  • C++:类和对象(上篇)
  • 氧化铝电容的工艺结构原理及选型参数总结
  • 野火ESP8266模块开发-基于Arduino IDE
  • [Qt学习笔记]Qt实现自定义控件SwitchButton开关按钮
  • 【工具】mac 环境配置
  • 【前端寻宝之路】学习和总结HTML的标签属性
  • kafka2.x版本配置SSL进行加密和身份验证
  • Linux和Windows下的文件批量重命名
  • stm32之GPIO电路介绍
  • Unity Toggle处理状态变化事件
  • UE5.1 iClone8 正确导入角色骨骼与动作
  • FFmpeg-- c++实现:pcm和yuv编码
  • 图解CodeWhisperer的安装使用
  • Python内置对象
  • 开源数据集 nuScenes 之 3D Occupancy Prediction
  • 物联网竞赛板CubMx全部功能简洁配置汇总
  • 使用Redis做缓存的小案例
  • 剧本杀小程序功能介绍
  • C#基础语法学习笔记(传智播客学习)
  • 图论01-DFS和BFS(深搜和广搜邻接矩阵和邻接表/Java)
  • 【Python】Miniconda+Vscode+Jupyter 环境搭建
  • Redis消息队列与thinkphp/queue操作
  • 【Ubuntu】常用命令
  • 稀碎从零算法笔记Day22-LeetCode: