Skip to content

Commit

Permalink
Merge pull request gree#478 from gree/refactoring/build_steps
Browse files Browse the repository at this point in the history
Refactoring/build steps
  • Loading branch information
KojiNakamaru authored Nov 28, 2019
2 parents f5bff47 + 96c9f66 commit afe2e14
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 281 deletions.
99 changes: 0 additions & 99 deletions WebPlayerTemplates/unity-webview/unity-webview.js

This file was deleted.

2 changes: 1 addition & 1 deletion build/Packager/Assets/Editor/Packager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Packager
public static void Export()
{
AssetDatabase.ExportPackage(
new string[]{"Assets/Plugins", "Assets/WebPlayerTemplates"},
new string[]{"Assets/Plugins", "Assets/WebGLTemplates", "Assets/WebPlayerTemplates"},
"unity-webview.unitypackage",
ExportPackageOptions.Recurse);
}
Expand Down
31 changes: 12 additions & 19 deletions build/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,38 @@ require 'fileutils'

UNITY="/Applications/UnityCurrent/Unity.app/Contents"

# NOTE: WebPlayerTemplates is not inclued for now because the sample app becomes complicated.
#
# CNT = 1
CNT = 1
CNT = 2
SRCDIR = Array.new(CNT);
DSTDIR = Array.new(CNT);
SRCS = Array.new(CNT);

SRCDIR[0]="../plugins"
DSTDIR[0]="Packager/Assets/Plugins"
SRCS[0]=%W|
Editor/UnityWebViewPostprocessBuild.cs
WebViewObject.cs
iOS/WebView.mm
Editor/UnityWebViewPostprocessBuild.cs
unity-webview-webgl-plugin.jslib
|
SRCDIR[1]="../plugins"
DSTDIR[1]="Packager/Assets"
SRCS[1]=%W|
WebGLTemplates
WebPlayerTemplates
|

# NOTE: WebPlayerTemplates is not inclued for now because the sample app becomes complicated.
#
# DSTDIR[1]="Packager/Assets/WebPlayerTemplates"
# SRCDIR[1]="../WebPlayerTemplates"
# SRCS[1]=%W|
# unity-webview/index.html
# unity-webview/thumbnail.png
# unity-webview/unity-webview.js
# |

task :default => ["build"]

desc "build"
task :build do
DSTDIR.each do |dir|
FileUtils.rm_rf dir
FileUtils.mkdir_p dir
sh "git clean -dxf ."
end
CNT.times do |i|
SRCS[i].each do |src|
dstdir = "#{DSTDIR[i]}/#{File.dirname(src)}"
FileUtils.mkdir_p dstdir
FileUtils.cp "#{SRCDIR[i]}/#{src}", dstdir, {:preserve => true}
FileUtils.cp_r "#{SRCDIR[i]}/#{src}", dstdir, {:preserve => true}
end
end
["Android"].each do |t|
Expand All @@ -79,7 +72,7 @@ desc "pack"
task :pack do
sh "#{UNITY}/MacOS/Unity -projectPath `pwd`/Packager -batchmode -quit -executeMethod Packager.Export -logFile LOG"
FileUtils.mv "Packager/unity-webview.unitypackage", "../dist"
sh "(cd Packager; rm -f ../../dist/unity-webview.zip; zip -qr9 ../../dist/unity-webview.zip `find Assets/Plugins -type f`)"
sh "(cd Packager; rm -f ../../dist/unity-webview.zip; zip -qr9 ../../dist/unity-webview.zip `find Assets/Plugins -type f` `find Assets/WebGLTemplates -type f` `find Assets/WebPlayerTemplates -type f`)"
end

desc "commit"
Expand Down
2 changes: 1 addition & 1 deletion plugins/Android/gradle_build/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'

dependencies {
provided files('./libs/classes.jar')
compileOnly files('./libs/classes.jar')
implementation 'com.android.support:appcompat-v7:23.3.0'
implementation 'com.android.support:support-v4:23.3.0'
}
Expand Down
3 changes: 0 additions & 3 deletions plugins/Editor/UnityWebViewPostprocessBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,8 @@ internal XmlNode GetActivityWithLaunchIntent() {
internal bool SetHardwareAccelerated(bool enabled) {
bool changed = false;
var activity = GetActivityWithLaunchIntent() as XmlElement;
Debug.Log(activity.GetAttribute("hardwareAccelerated", AndroidXmlNamespace));
if (activity.GetAttribute("hardwareAccelerated", AndroidXmlNamespace) != ((enabled) ? "true" : "false")) {
Debug.Log("HERE");
activity.SetAttribute("hardwareAccelerated", AndroidXmlNamespace, (enabled) ? "true" : "false");
Debug.Log(activity.GetAttribute("hardwareAccelerated", AndroidXmlNamespace));
changed = true;
}
return changed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/WebGL-test.json", {onProgress: UnityProgress});
var unityInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%", {onProgress: UnityProgress});
</script>
</head>
<body>
Expand All @@ -20,7 +20,7 @@
<div id="gameContainer" style="width: 960px; height: 600px"></div>
<div class="footer">
<div class="webgl-logo"></div>
<div class="fullscreen" onclick="gameInstance.SetFullscreen(1)"></div>
<div class="fullscreen" onclick="unityInstance.SetFullscreen(1)"></div>
<div class="title">Title</div>
</div>
</div>
Expand All @@ -29,4 +29,4 @@
<!-- unity_webview -->
<script type="text/javascript" src="unity-webview.js"></script>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var unityWebView =
contents.find('a').click(function (e) {
var href = $.trim($(this).attr('href'));
if (href.substr(0, 6) === 'unity:') {
u.getUnity().SendMessage(name, "CallFromJS", href.substring(6, href.length));
unityInstance.SendMessage(name, "CallFromJS", href.substring(6, href.length));
e.preventDefault();
} else {
w.location.replace(href);
Expand All @@ -37,7 +37,7 @@ var unityWebView =
if ($this.attr('method').toLowerCase() == 'get') {
message += '?' + $this.serialize();
}
u.getUnity().SendMessage(name, "CallFromJS", message);
unityInstance.SendMessage(name, "CallFromJS", message);
return false;
}
return true;
Expand All @@ -46,7 +46,7 @@ var unityWebView =
},

sendMessage: function (name, message) {
u.getUnity().SendMessage(name, "CallFromJS", message);
unityInstance.SendMessage(name, "CallFromJS", message);
},

setMargins: function (name, left, top, right, bottom) {
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions plugins/WebViewObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ public void Init(
onStarted = started;
onLoaded = ld;
#if UNITY_WEBGL
#if !UNITY_EDITOR
_gree_unity_webview_init(name);
#endif
#elif UNITY_WEBPLAYER
Application.ExternalCall("unityWebView.init", name);
#elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
Expand Down Expand Up @@ -419,7 +421,9 @@ public void Init(
protected virtual void OnDestroy()
{
#if UNITY_WEBGL
#if !UNITY_EDITOR
_gree_unity_webview_destroy(name);
#endif
#elif UNITY_WEBPLAYER
Application.ExternalCall("unityWebView.destroy", name);
#elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
Expand Down Expand Up @@ -481,7 +485,9 @@ public void SetMargins(int left, int top, int right, int bottom, bool relative =
mMarginRight = right;
mMarginBottom = bottom;
#if UNITY_WEBGL
#if !UNITY_EDITOR
_gree_unity_webview_setMargins(name, left, top, right, bottom);
#endif
#elif UNITY_WEBPLAYER
Application.ExternalCall("unityWebView.setMargins", name, left, top, right, bottom);
#elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
Expand Down Expand Up @@ -515,7 +521,9 @@ public void SetMargins(int left, int top, int right, int bottom, bool relative =
public void SetVisibility(bool v)
{
#if UNITY_WEBGL
#if !UNITY_EDITOR
_gree_unity_webview_setVisibility(name, v);
#endif
#elif UNITY_WEBPLAYER
Application.ExternalCall("unityWebView.setVisibility", name, v);
#elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
Expand Down Expand Up @@ -547,7 +555,9 @@ public void LoadURL(string url)
if (string.IsNullOrEmpty(url))
return;
#if UNITY_WEBGL
#if !UNITY_EDITOR
_gree_unity_webview_loadURL(name, url);
#endif
#elif UNITY_WEBPLAYER
Application.ExternalCall("unityWebView.loadURL", name, url);
#elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
Expand Down Expand Up @@ -587,7 +597,9 @@ public void LoadHTML(string html, string baseUrl)
public void EvaluateJS(string js)
{
#if UNITY_WEBGL
#if !UNITY_EDITOR
_gree_unity_webview_evaluateJS(name, js);
#endif
#elif UNITY_WEBPLAYER
Application.ExternalCall("unityWebView.evaluateJS", name, js);
#elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
Expand Down
2 changes: 0 additions & 2 deletions sample/Assets/WebPlayerTemplates.meta

This file was deleted.

2 changes: 0 additions & 2 deletions sample/Assets/WebPlayerTemplates/unity-webview.meta

This file was deleted.

Loading

0 comments on commit afe2e14

Please sign in to comment.