Skip to content

Commit

Permalink
Merge pull request #1082 from gree/feature/install_sh_zorderpatch_option
Browse files Browse the repository at this point in the history
modified install.sh to remove the zorder patch for 5.6.x by default.
  • Loading branch information
KojiNakamaru authored Jul 11, 2024
2 parents b2f9025 + d8818da commit 512c71c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ This plugin adjusts the bottom margin temporarily when the keyboard pops up to k

UnityWebViewPostprocessBuild.cs will select one of WebViewPlugin-*.aar.tmpl depending on EditorUserSettings.development. You can build these files as below:

1. Install Unity 5.6.1f1 and 2019.4.40f1 (both with Android Build Support) by Unity Hub.
1. Install Unity 2019.4.40f1 with Android Build Support by Unity Hub.
* Also install Unity 5.6.1f1 from https://unity.com/ja/releases/editor/whats-new/5.6.1 and specify `--zorderpatch` if you need to include CUnityPlayer and CUnityPlayerActivity (cf. [Unity 5.x or older](#unity-5x-or-older)).
2. Open Terminal (mac) or Git Bash (windows), `cd plugins/Android`, and invoke `./install.sh`.

If successful, you should find `build/Packager/Assets/Plugins/Android/WebViewPlugin-*.aar.tmpl`. install.sh has the following options:
Expand All @@ -314,6 +315,7 @@ Options:
--nofragment build a nofragment variant.
--development build a development variant.
--zorderpatch build with the patch for 5.6.0 and 5.6.1 (except 5.6.1p4)
```

Expand Down
49 changes: 34 additions & 15 deletions plugins/Android/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ Darwin)
export JAVA_HOME='/Applications/Unity/Hub/Editor/2019.4.40f1/PlaybackEngines/AndroidPlayer/OpenJDK'
export ANDROID_SDK_ROOT='/Applications/Unity/Hub/Editor/2019.4.40f1/PlaybackEngines/AndroidPlayer/SDK'
export PATH=$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/tools/bin:$JAVA_HOME/bin:$PATH
UNITY='/Applications/Unity/Hub/Editor/5.6.1f1'
;;
MINGW64_NT*)
export JAVA_HOME='/c/PROGRA~1/Unity/Hub/Editor/2019.4.40f1/Editor/Data/PlaybackEngines/AndroidPlayer/OpenJDK'
export ANDROID_SDK_ROOT='/c/PROGRA~1/Unity/Hub/Editor/2019.4.40f1/Editor/Data/PlaybackEngines/AndroidPlayer/SDK'
export PATH=$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/tools/bin:$JAVA_HOME/bin:$PATH
UNITY='/c/PROGRA~1/Unity/Hub/Editor/5.6.1f1/Editor/Data'
;;
esac
DEST_DIR='../../build/Packager/Assets/Plugins/Android'
Expand All @@ -26,15 +24,11 @@ then
echo 'From Unity Hub, please install 2019.4.40f1 with the android module.'
exit 1
fi
if [ ! -d "$UNITY" ]
then
echo 'From Unity Hub, please install 5.6.1f1 with the android module.'
exit 1
fi

# options
TARGET="webview"
MODE="Release"
UNITY='2019.4.40f1'
for OPT in $*
do
case $OPT in
Expand All @@ -44,6 +38,9 @@ do
'--development')
MODE="Development"
;;
'--zorderpatch')
UNITY='5.6.1f1'
;;
*)
cat <<EOF
Usage: ./install.sh [OPTIONS]
Expand All @@ -52,40 +49,62 @@ Options:
--nofragment build a nofragment variant.
--development build a development variant.
--zorderpatch build with the patch for 5.6.0 and 5.6.1 (except 5.6.1p4).
EOF
exit 1
;;
esac
done
UNITY_JAVA_LIB="${UNITY}/PlaybackEngines/AndroidPlayer/Variations/il2cpp/${MODE}/Classes/classes.jar"

# save original CWebViewPlugin.java
case $(uname) in
Darwin)
UNITY_DIR="/Applications/Unity/Hub/Editor/${UNITY}"
;;
MINGW64_NT*)
UNITY_DIR='/c/PROGRA~1/Unity/Hub/Editor/${UNITY}/Editor/Data'
;;
esac
if [ ! -d "$UNITY_DIR" ]
then
echo 'From Unity Hub, please install $UNITY with the android module.'
exit 1
fi

# save original *.java
tmp=$(mktemp -d -t _client_sh.XXX)
cp -a "${TARGET}/src/main/java/net/gree/unitywebview/CWebViewPlugin.java" $tmp/CWebViewPlugin.java
cp -a ${TARGET}/src/main/java/net/gree/unitywebview/*.java $tmp
cleanup() {
ret=$?
cp -a $tmp/CWebViewPlugin.java "${TARGET}/src/main/java/net/gree/unitywebview/CWebViewPlugin.java"
cp -a $tmp/*.java ${TARGET}/src/main/java/net/gree/unitywebview
exit $ret
}
trap cleanup EXIT

# emit CWebViewPlugin.java
# adjust CWebViewPlugin.java
case $MODE in
'Release')
dst=${DEST_DIR}/WebViewPlugin-release.aar.tmpl
sed '/^\/\/#if UNITYWEBVIEW_DEVELOPMENT$/,/^\/\/#endif$/d' < $tmp/CWebViewPlugin.java > "${TARGET}/src/main/java/net/gree/unitywebview/CWebViewPlugin.java"
sed '/^\/\/#if UNITYWEBVIEW_DEVELOPMENT$/,/^\/\/#endif$/d' < $tmp/CWebViewPlugin.java > ${TARGET}/src/main/java/net/gree/unitywebview/CWebViewPlugin.java
;;
*)
dst=${DEST_DIR}/WebViewPlugin-development.aar.tmpl
cp -a $tmp/CWebViewPlugin.java "${TARGET}/src/main/java/net/gree/unitywebview/CWebViewPlugin.java"
cp -a $tmp/CWebViewPlugin.java ${TARGET}/src/main/java/net/gree/unitywebview/CWebViewPlugin.java
;;
esac
# remove CUnityPlayer*.java if UNITY != 5.6.1f1.
case $UNITY in
'5.6.1f1')
;;
*)
rm -f ${TARGET}/src/main/java/net/gree/unitywebview/CUnityPlayer*.java
;;
esac

pushd $CWD

# build
cp ${UNITY_JAVA_LIB} ${TARGET}/libs
cp "${UNITY_DIR}/PlaybackEngines/AndroidPlayer/Variations/il2cpp/${MODE}/Classes/classes.jar" ${TARGET}/libs
./gradlew clean -p $TARGET
./gradlew assembleRelease -p $TARGET

Expand Down

0 comments on commit 512c71c

Please sign in to comment.