Skip to content

Commit a9909c4

Browse files
authored
Merge pull request #305 from immutable/feature/sdk-3343-indexhtml
[SDK-3343] use unity global var instead of hardcoded
2 parents b858bca + b0a3af5 commit a9909c4

25 files changed

+21
-613
lines changed

WebGL.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ Live example can be found at https://immutable.github.io/unity-immutable-sdk/sam
1111

1212
WebGL template is a configuration setting that lets you control the appearance of the HTML page, so that you can: test, demonstrate, and preview your WebGL application in a browser.
1313

14-
A WebGL Template is always needed for creating a WebGL application and it will always be stored within **Assets > WebGL Templates** to be used. You can refer to [Unity: WebGL Templates](https://docs.unity3d.com/Manual/webgl-templates.html) for more information.
14+
1. Create a custom WebGL template:
15+
- Navigate to **Assets > WebGLTemplates** in your Unity project.
16+
- Copy one of the built-in templates (Default or Minimal) from **[Unity Installation] > PlaybackEngines > WebGLSupport > BuildTools > WebGLTemplates**.
17+
- Rename the copied template to something meaningful for your project.
1518

16-
A Custom WebGL Template is required to implement the Immutable Unity SDK in WebGL projects. The easiest way to create a new custom WebGL template is to make a copy of the built-in Default or Minimal templates, which are stored in corresponding subfolders under <Unity Installation> > PlaybackEngines > WebGLSupport > BuildTools > WebGLTemplates.
17-
18-
Every Unity Project includes these templates by default. Copy a template and place it in your own **Assets > WebGLTemplates** folder, and rename it to something meaningful so you can identify your template later.
19-
20-
Once you have created your own template, copy the following files from Passport package into the **Assets > WebGLTemplates** folder:
19+
2. Copy the following files from the Passport package into your **Assets > WebGLTemplates** folder:
2120
- `Packages/Immutable Passport/WebGLTemplates~/unity-webview.js`
2221
- `Packages/Immutable Passport/WebGLTemplates~/callback.html`
2322
- `Packages/Immutable Passport/WebGLTemplates~/logout.html`
@@ -35,6 +34,7 @@ Once you have created your own template, copy the following files from Passport
3534
Follow these steps for implementation:
3635
> [!NOTE]
3736
> You can rename `callback.html` and `logout.html` to suit your project needs.
37+
> For local testing with WebGL builds, note the random port number assigned (e.g., http://localhost:60750). You may need to update the Hub Passport config each time you start a new local WebGL build, as the port number may change.
3838
1. Define a deep link scheme for your game:
3939
- Redirect URL: https://game.domain.com/callback.html
4040
- Logout URL: https://game.domain.com/logout.html

src/Packages/Passport/Samples~/sample/Assets/WebGLTemplates/unity-webview/callback.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6-
<title>Unity WebGL Player | Immutable SDK Sample App</title>
6+
<title>Unity WebGL Player | {{{ PRODUCT_NAME }}}</title>
77
<link rel="shortcut icon" href="TemplateData/favicon.ico">
88
<link rel="stylesheet" href="TemplateData/style.css">
99
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

src/Packages/Passport/Samples~/sample/Assets/WebGLTemplates/unity-webview/index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6-
<title>Unity WebGL Player | Immutable SDK Sample App</title>
6+
<title>Unity WebGL Player | {{{ PRODUCT_NAME }}}</title>
77
<link rel="shortcut icon" href="TemplateData/favicon.ico">
88
<link rel="stylesheet" href="TemplateData/style.css">
99
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
@@ -21,36 +21,36 @@
2121
<div id="unity-footer">
2222
<div id="unity-webgl-logo"></div>
2323
<div id="unity-fullscreen-button"></div>
24-
<div id="unity-build-title">Immutable SDK Sample App</div>
24+
<div id="unity-build-title">{{{ PRODUCT_NAME }}}</div>
2525
</div>
2626
</div>
2727
<script>
2828
var buildUrl = "Build";
29-
var loaderUrl = buildUrl + "/webgl.loader.js";
29+
var loaderUrl = buildUrl + "/{{{ LOADER_FILENAME }}}";
3030
var config = {
31-
dataUrl: buildUrl + "/webgl.data",
32-
frameworkUrl: buildUrl + "/webgl.framework.js",
33-
codeUrl: buildUrl + "/webgl.wasm",
31+
dataUrl: buildUrl + "/{{{ DATA_FILENAME }}}",
32+
frameworkUrl: buildUrl + "/{{{ FRAMEWORK_FILENAME }}}",
33+
codeUrl: buildUrl + "/{{{ CODE_FILENAME }}}",
3434
streamingAssetsUrl: "StreamingAssets",
35-
companyName: "Immutable",
36-
productName: "Immutable SDK Sample App",
37-
productVersion: "0.1.0",
35+
companyName: "{{{ COMPANY_NAME }}}",
36+
productName: "{{{ PRODUCT_NAME }}}",
37+
productVersion: "{{{ PRODUCT_VERSION }}}",
3838
};
3939

4040
var container = document.querySelector("#unity-container");
4141
var canvas = document.querySelector("#unity-canvas");
4242
var loadingBar = document.querySelector("#unity-loading-bar");
4343
var progressBarFull = document.querySelector("#unity-progress-bar-full");
4444
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
45-
var width0 = "960px";
46-
var height0 = "600px";
45+
var width0 = "{{{ WIDTH }}}px";
46+
var height0 = "{{{ HEIGHT }}}px";
4747

4848
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
4949
container.className = "unity-mobile";
5050
config.devicePixelRatio = 1;
5151
} else {
52-
canvas.style.width = "960px";
53-
canvas.style.height = "600px";
52+
canvas.style.width = "{{{ WIDTH }}}px";
53+
canvas.style.height = "{{{ HEIGHT }}}px";
5454
}
5555
loadingBar.style.display = "block";
5656

src/Packages/Passport/Samples~/sample/Assets/WebGLTemplates/unity-webview/logout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6-
<title>Unity WebGL Player | Immutable SDK Sample App</title>
6+
<title>Unity WebGL Player | {{{ PRODUCT_NAME }}}</title>
77
<link rel="shortcut icon" href="TemplateData/favicon.ico">
88
<link rel="stylesheet" href="TemplateData/style.css">
99
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
Binary file not shown.

src/Packages/Passport/Samples~/sample/webgl/Build/webgl.framework.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/Packages/Passport/Samples~/sample/webgl/Build/webgl.loader.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)