Unreal学习笔记 - 修复右键菜单

背景

重装了一下Unreal。发现不知道为什么.uproject文件没有被自动关联。谷歌了一下找到了修复的解决方案。
原文:http://www.davidmoore.info/blog/2014/09/05/fix-the-missing-right-click-menu-for-unreal-engine-projects-uproject/

不过可能是因为适用于老版本的Unreal。新版本的Unreal的文件结构发生了变化。包括很多谷歌上的描述也是使用的原文的结构。而我用的Unreal 4.13.1版本并不适用。因此进行了一些修改。贴出解决方案cmd命令行文件。
不过该版本适用于自编译的Unreal引擎。对于使用Launcher安装的版本来说并不适用因此在原来的基础上进行了一些修改具体代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
:: UnrealProjectMenuRegistration.cmd
::
:: This batch file will try to find where the Unreal Engine is installed, then update your registry
:: to register the Unreal Project File type (and its right click menu for things such as generating
:: Visual Studio project files, and launching)
::
:: Run as an Administrator, as it's required for writing to HKLM.
::
:: Author: David Moore <[email protected]>
::
:: 二次修改:moonrailgun
:: http://www.moonrailgun.com/

::@ECHO OFF

echo.
echo Locating where Unreal Engine Launcher...
set UnrealLauncherDir= %~pd0

IF "%UnrealLauncherDir%"=="" GOTO CannotFindUnrealEngine

echo.
echo Using Unreal Engine directory: %UnrealLauncherDir%

set LauncherPath=%UnrealLauncherDir%Engine\Binaries\Win64\UnrealVersionSelector.exe

echo.
echo Adding registry keys for the Unreal Project right click menu...

:: HKLM\SOFTWARE\Classes\.uproject
reg ADD "HKLM\Software\Classes\.uproject" /ve /d Unreal.ProjectFile /f
IF ERRORLEVEL 1 (
echo Couldn't write to registry. Did you forget to run this batch file as an administrator?
goto TheEnd
)

:: HKLM\SOFTWARE\Classes\Unreal.ProjectFile
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile" /ve /d "Unreal Engine Project File" /f

:: HKLM\SOFTWARE\Classes\Unreal.ProjectFile\DefaultIcon
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\DefaultIcon" /ve /d "\"%LauncherPath%\"" /f

:: HKLM\SOFTWARE\Classes\Unreal.ProjectFile\shell\open
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\open" /ve /d "Open" /f
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\open\command" /ve /d "\"%LauncherPath%\" /editor \"%%1\"" /f

:: HKLM\SOFTWARE\Classes\Unreal.ProjectFile\shell\run
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\run" /ve /d "Launch game" /f
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\run" /v Icon /t REG_SZ /d "\"%LauncherPath%\"" /f
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\run\command" /ve /d "\"%LauncherPath%\" /game \"%%1\"" /f

:: HKLM\SOFTWARE\Classes\Unreal.ProjectFile\shell\rungenproj
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\rungenproj" /ve /d "Generate Visual Studio project files" /f
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\rungenproj" /v Icon /t REG_SZ /d "\"%LauncherPath%\"" /f
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\rungenproj\command" /ve /d "\"%LauncherPath%\" /projectfiles \"%%1\"" /f

:: HKLM\SOFTWARE\Classes\Unreal.ProjectFile\shell\switchversion
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\switchversion" /ve /d "Switch Unreal Engine version..." /f
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\switchversion" /v Icon /t REG_SZ /d "\"%LauncherPath%\"" /f
reg ADD "HKLM\Software\Classes\Unreal.ProjectFile\shell\switchversion\command" /ve /d "\"%LauncherPath%\" /switchversion \"%%1\"" /f

:Done
echo.
echo Done.
echo.
goto TheEnd

:CannotFindUnrealEngine
echo.
echo DOH! Can't find the Unreal Engine.
echo.
goto TheEnd

:TheEnd
pause

用法

将文件保存为UnrealProjectMenuRegistration.cmd到Epic Game根目录下(Epic Games\Launcher\UnrealProjectMenuRegistration.cmd)
右键点击以管理员的身份运行。如果有杀软拦截请选择允许
完成后尝试重启电脑/重启Epic Games Launcher完成关联操作

文章目录
  1. 1. 背景
  2. 2. 用法