4
4
# This script is used to run a Unity game with BepInEx enabled.
5
5
#
6
6
# Usage: Configure the script below and simply run this script when you want to run your game modded.
7
+ a=" /$0 " ; a=${a%/* } ; a=${a#/ } ; a=${a:- .} ; BASEDIR=$( cd " $a " ; pwd -P)
7
8
8
9
# -------- SETTINGS --------
9
10
# ---- EDIT AS NEEDED ------
@@ -19,31 +20,42 @@ executable_name=""
19
20
export DOORSTOP_ENABLE=TRUE
20
21
21
22
# What .NET assembly to execute. Valid value is a path to a .NET DLL that mono can execute.
22
- export DOORSTOP_INVOKE_DLL_PATH=" ${PWD} /BepInEx/core/BepInEx.Preloader.dll"
23
+ export DOORSTOP_INVOKE_DLL_PATH=" ${BASEDIR} /BepInEx/core/BepInEx.Preloader.Unity.dll"
24
+
25
+ # If specified, Doorstop will load core libraries from this folder instead of the normal Managed folder
26
+ # Mainly usable to unstrip assemblies in some games
27
+ export DOORSTOP_CORLIB_OVERRIDE_PATH=" "
23
28
24
29
# ----- DO NOT EDIT FROM THIS LINE FORWARD ------
25
30
# ----- (unless you know what you're doing) ------
26
31
32
+ # Special case: program is launched via Steam
33
+ # In that case rerun the script via their bootstrapper to ensure Steam overlay works
34
+ if [ " $2 " = " SteamLaunch" ]; then
35
+ " $1 " " $2 " " $3 " " $4 " " $0 " " $5 " " ${@: 6} "
36
+ exit
37
+ fi
38
+
27
39
if [ ! -x " $1 " -a ! -x " $executable_name " ]; then
28
40
echo " Please open run.sh in a text editor and configure executable name."
29
41
exit 1
30
42
fi
31
43
32
- doorstop_libs=" ${PWD} /doorstop_libs"
44
+ doorstop_libs=" $BASEDIR /doorstop_libs"
33
45
arch=" "
34
46
executable_path=" "
35
47
lib_postfix=" "
36
48
37
- os_type=` uname -s`
49
+ os_type=$( uname -s)
38
50
case $os_type in
39
51
Linux* )
40
- executable_path=" ${PWD} /${executable_name} "
52
+ executable_path=" $BASEDIR /${executable_name} "
41
53
lib_postfix=" so"
42
54
;;
43
55
Darwin* )
44
- executable_name=` basename " ${executable_name} " .app`
45
- real_executable_name=` defaults read " ${PWD} /${executable_name} .app/Contents/Info" CFBundleExecutable`
46
- executable_path=" ${PWD} /${executable_name} .app/Contents/MacOS/${real_executable_name} "
56
+ executable_name=$( basename " ${executable_name} " .app)
57
+ real_executable_name=$( defaults read " $BASEDIR /${executable_name} .app/Contents/Info" CFBundleExecutable)
58
+ executable_path=" $BASEDIR /${executable_name} .app/Contents/MacOS/${real_executable_name} "
47
59
lib_postfix=" dylib"
48
60
;;
49
61
* )
@@ -63,10 +75,10 @@ if [ -n "$1" ]; then
63
75
;;
64
76
Darwin* )
65
77
# Special case: allow to specify path to the executable within .app
66
- full_path_part=` echo " $1 " | grep " \.app/Contents/MacOS" `
78
+ full_path_part=$( echo " $1 " | grep " \.app/Contents/MacOS" )
67
79
if [ -z " $full_path_part " ]; then
68
- executable_name=` basename " $1 " .app`
69
- real_executable_name=` defaults read " $1 /Contents/Info" CFBundleExecutable`
80
+ executable_name=$( basename " $1 " .app)
81
+ real_executable_name=$( defaults read " $1 /Contents/Info" CFBundleExecutable)
70
82
executable_path=" $1 /Contents/MacOS/${real_executable_name} "
71
83
else
72
84
executable_path=" $1 "
@@ -75,9 +87,42 @@ if [ -n "$1" ]; then
75
87
esac
76
88
fi
77
89
78
- executable_type=` LD_PRELOAD=" " file -b " ${executable_path} " ` ;
90
+ abs_path () {
91
+ echo " $( cd " $( dirname " $1 " ) " && pwd) /$( basename " $1 " ) "
92
+ }
93
+
94
+ _readlink () {
95
+ # relative links with readlink (without -f) do not preserve the path info
96
+ ab_path=" $( abs_path " $1 " ) "
97
+ link=" $( readlink " ${ab_path} " ) "
98
+ case $link in
99
+ /* );;
100
+ * ) link=" $( dirname " $ab_path " ) /$link " ;;
101
+ esac
102
+ echo " $link "
103
+ }
104
+
105
+
106
+ resolve_executable_path () {
107
+ e_path=" $( abs_path " $1 " ) "
108
+
109
+ while [ -L " ${e_path} " ]; do
110
+ e_path=$( _readlink " ${e_path} " ) ;
111
+ done
112
+ echo " ${e_path} "
113
+ }
114
+
115
+ executable_path=$( resolve_executable_path " ${executable_path} " )
116
+ echo " ${executable_path} "
117
+ executable_type=$( LD_PRELOAD=" " file -b " ${executable_path} " ) ;
79
118
80
119
case $executable_type in
120
+ * PE32* )
121
+ echo " The executable is a Windows executable file. You must use Wine/Proton and BepInEx for Windows with this executable."
122
+ echo " Uninstall BepInEx for *nix and install BepInEx for Windows instead."
123
+ echo " More info: https://docs.bepinex.dev/articles/advanced/steam_interop.html#protonwine"
124
+ exit 1
125
+ ;;
81
126
* 64-bit* )
82
127
arch=" x64"
83
128
;;
@@ -97,4 +142,4 @@ export LD_PRELOAD=$doorstop_libname:$LD_PRELOAD
97
142
export DYLD_LIBRARY_PATH=" ${doorstop_libs} "
98
143
export DYLD_INSERT_LIBRARIES=" ${doorstop_libs} /$doorstop_libname "
99
144
100
- " ${executable_path} "
145
+ " ${executable_path} " " $@ "
0 commit comments