Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #56 from cvan/add-manifest
Browse files Browse the repository at this point in the history
add default Web-App Manifest; add default `favicon.ico` (fixes #52; fixes #51)
  • Loading branch information
cvan authored Dec 20, 2017
2 parents 31877d9 + d57d399 commit 25351ba
Show file tree
Hide file tree
Showing 28 changed files with 158 additions and 19 deletions.
Binary file added Assets/WebGLTemplates/WebVR/favicon.ico
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Assets/WebGLTemplates/WebVR/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>%UNITY_WEB_NAME%</title>
<meta name="description" content="%UNITY_WEB_NAME%">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="webvr.css" />
<script src="Build/UnityLoader.js"></script>
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="webvr.css">
<script src="%UNITY_WEBGL_LOADER_URL%"></script>
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%", {
// Preserve drawing buffer is needed for WebVR content to be mirrored out into canvas.
Module:{"webglContextAttributes": { "preserveDrawingBuffer" : true }},
Module: {"webglContextAttributes": { "preserveDrawingBuffer" : true }},
onProgress: unityProgress
});

Expand All @@ -25,6 +25,7 @@
gameInstance.progress.style.width = (100 * progress) + "%";
}
</script>
<link rel="manifest" href="manifest.webmanifest">
</head>

<body>
Expand Down Expand Up @@ -66,4 +67,4 @@ <h3>You'll need a <a href="https://webvr.rocks/">WebVR enabled browser</a><br/>
<script src="webvr.js"></script>
</body>

</html>
</html>
53 changes: 53 additions & 0 deletions Assets/WebGLTemplates/WebVR/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"lang": "en",
"dir": "ltr",
"name": "Unity WebVR Game",

This comment has been minimized.

Copy link
@caseyyee

caseyyee Dec 21, 2017

Contributor

Did we ever figure out a way to use the template strings for this?

May want to start using a script that will compile all this together so that users don't need to edit this every time they build the project.

"short_name": "Unity WebVR",
"description": "WebVR Game exported from Unity.",
"start_url": "./?src=manifest",
"display": "standalone",
"background_color": "#111",
"theme_color": "#111",
"icons": [

This comment has been minimized.

Copy link
@caseyyee
{
"src": "vr.png",
"sizes": "200x200",
"type": "image/png"
},
{
"src": "favicon.ico",
"sizes": "16x16 32x32 48x48 64x64 256x256",
"type": "image/x-icon"
}
],
"screenshots": [
{
"src": "https://raw.githubusercontent.com/caseyyee/unity-webvr-export/master/img/preview.gif",
"sizes": "640x360",
"type": "image/gif",
"purpose": "Animation of WebVR game exported from Unity"
}
],
"categories": [
"games",
"unity",
"webvr",
"unity-webvr"
],
"xr_available_platforms": [
{
"platform": "windows",
"browser": "firefox"
},
{
"platform": "windows",
"browser": "edge"
}
],
"xr_default_device": "htc_vive",
"xr_available_devices": [

This comment has been minimized.

Copy link
@caseyyee

caseyyee Dec 21, 2017

Contributor

Is there any need to track controller capabilities? I'm thinking the other thing we could do is have the Unity WebVR component check for usage and appropriately configure the manifest. Probably more of a future thing.

"htc_vive",
"oculus_rift"
],
"unity_webvr_player_version": "0.0.0"
}
9 changes: 9 additions & 0 deletions Assets/WebGLTemplates/WebVR/manifest.webmanifest.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/WebGLTemplates/WebVR/motion-controllers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/WebGLTemplates/WebVR/mousedrag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/WebGLTemplates/WebVR/vr.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Build/Build/Build.asm.code.unityweb
Binary file not shown.
Binary file modified Build/Build/Build.asm.framework.unityweb
Binary file not shown.
Binary file modified Build/Build/Build.asm.memory.unityweb
Binary file not shown.
Binary file modified Build/Build/Build.data.unityweb
Binary file not shown.
Binary file modified Build/Build/Build.wasm.code.unityweb
Binary file not shown.
Binary file modified Build/Build/Build.wasm.framework.unityweb
Binary file not shown.
Binary file added Build/favicon.ico
Binary file not shown.
9 changes: 5 additions & 4 deletions Build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unity-WebVR-Export</title>
<meta name="description" content="Unity-WebVR-Export">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="webvr.css" />
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="webvr.css">
<script src="Build/UnityLoader.js"></script>
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/Build.json", {
// Preserve drawing buffer is needed for WebVR content to be mirrored out into canvas.
Module:{"webglContextAttributes": { "preserveDrawingBuffer" : true }},
Module: {"webglContextAttributes": { "preserveDrawingBuffer" : true }},
onProgress: unityProgress
});

Expand All @@ -25,6 +25,7 @@
gameInstance.progress.style.width = (100 * progress) + "%";
}
</script>
<link rel="manifest" href="manifest.webmanifest">
</head>

<body>
Expand Down Expand Up @@ -66,4 +67,4 @@ <h3>You'll need a <a href="https://webvr.rocks/">WebVR enabled browser</a><br/>
<script src="webvr.js"></script>
</body>

</html>
</html>
53 changes: 53 additions & 0 deletions Build/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"lang": "en",
"dir": "ltr",
"name": "Unity WebVR Game",
"short_name": "Unity WebVR",
"description": "WebVR Game exported from Unity.",
"start_url": "./?src=manifest",
"display": "standalone",
"background_color": "#111",
"theme_color": "#111",
"icons": [
{
"src": "vr.png",
"sizes": "200x200",
"type": "image/png"
},
{
"src": "favicon.ico",
"sizes": "16x16 32x32 48x48 64x64 256x256",
"type": "image/x-icon"
}
],
"screenshots": [
{
"src": "https://raw.githubusercontent.com/caseyyee/unity-webvr-export/master/img/preview.gif",
"sizes": "640x360",
"type": "image/gif",
"purpose": "Animation of WebVR game exported from Unity"
}
],
"categories": [
"games",
"unity",
"webvr",
"unity-webvr"
],
"xr_available_platforms": [
{
"platform": "windows",
"browser": "firefox"
},
{
"platform": "windows",
"browser": "edge"
}
],
"xr_default_device": "htc_vive",
"xr_available_devices": [
"htc_vive",
"oculus_rift"
],
"unity_webvr_player_version": "0.0.0"
}
Binary file modified Build/motion-controllers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Build/mousedrag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Build/vr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 13
productGUID: 001dddf64591e46339e4cbbc928aaa40
AndroidProfiler: 0
AndroidProfiler: 1
AndroidFilterTouchesWhenObscured: 0
defaultScreenOrientation: 4
targetDevice: 2
Expand Down
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,51 @@ Works with [HTC VIVE](https://webvr.rocks/htc_vive) and [Oculus Rift](https://we

## Setup instructions

With an existing Unity project:
This flow has been tested with Unity versions `2017.2.0f3` and later.

To export an existing Unity project to WebVR:

1. [**Download this ZIP file**](https://github.com/caseyyee/unity-webvr-export/archive/master.zip) containing the contents of this repository. Or you can clone the Git repository locally to your machine:
```sh
git clone https://github.com/caseyyee/unity-webvr-export.git && cd unity-webvr-export
```
2. Launch **Unity**.
2. Launch **Unity**. ([Download and install Unity](https://store.unity.com/download?ref=personal), or upgrade to the latest version, if you have not already.)
3. Open your existing Unity project: `File > Open Project`.
3. Open `File > Build Settings`, and select the `WebGL` platform.
4. Open **`File > Build Settings`**, and from the `Platform` list, select the **`WebGL`** platform.

<img src="https://raw.githubusercontent.com/caseyyee/unity-webvr-export/master/img/build-settings.png" width="550">

4. From `Player Settings` (`Edit > Project Settings > Player`), select the **`WebGL settings`** tab (HTML5 icon), toggle the **`Resolution and Presentation`** view, and select **`WebVR`** for the `WebGL Template`.
5. From **`Player Settings`** (`Edit > Project Settings > Player`), select the **`WebGL settings`** tab (HTML5 icon), toggle to the **`Resolution and Presentation`** view, and select **`WebVR`** for the `WebGL Template`.

<img src="https://raw.githubusercontent.com/caseyyee/unity-webvr-export/master/img/webgl-template.png" width="250">

5. Select **`File > Build & Run`**.
6. Select **`File > Build & Run`**.
> Or select `File > Build Settings …`, and choose a location for your build.
6. Once the build has completed, your web browser will automatically open the project. Make sure you are running the game in a [*WebVR-capable browser*](https://webvr.rocks/#browsers).
7. Once the build has completed, your web browser will automatically open the project. Make sure you are running the game in a [*WebVR-capable browser*](https://webvr.rocks/#browsers).
> Alternatively, if you ran `Build`, instead of `Build & Run`, you can run a [local static-file web server](https://aframe.io/docs/0.7.0/introduction/installation.html#use-a-local-server) and load the `index.html` document from your WebVR-capable browser.
## Update Asset Package
If you are a maintainer of the project, you will want to update the [`Build/` directory](https://github.com/caseyyee/unity-webvr-export/tree/master/Build/) (hosted [online here](https://caseyyee.github.io/unity-webvr-export/Build/)) and the [`WebVR-Assets.unitypackage` file](https://github.com/caseyyee/unity-webvr-export/blob/master/WebVR-Assets.unitypackage).
1. Launch `Edit > Build Settings > Project Settings`. From `Player Settings…` (`Edit > Project Settings > Player`), select the **`WebGL settings`** tab (HTML5 icon), toggle the **`Resolution and Presentation`** view, and select **`WebVR`** for the `WebGL Template`.
<img src="https://raw.githubusercontent.com/caseyyee/unity-webvr-export/master/img/webgl-template.png" width="250">
2. Launch `Edit > Build Settings > Project Settings`. Then, press the **`Build and Run`** button, and select the directory named `Build` as the destination directory.
<img src="https://raw.githubusercontent.com/caseyyee/unity-webvr-export/master/img/build-webgl.png" width="250">
3. Open **`Assets > Export Package…`**, and press the **`Export…`** button.
<img src="https://raw.githubusercontent.com/caseyyee/unity-webvr-export/master/img/export-asset-package.png" width="250">
4. Set **`WebVR-Assets`** as the filename of the destination Unity Asset Package, and press the **`Save`** button.
<img src="https://raw.githubusercontent.com/caseyyee/unity-webvr-export/master/img/exporting-asset-package.png" width="250">
## License
All code and content within this source-code repository is, unless otherwise specified, licensed under the [**Creative Commons Zero v1.0 Universal** license (CC0 1.0 Universal; Public Domain Dedication)](LICENSE.md).
Expand Down
Binary file modified WebVR-Assets.unitypackage
Binary file not shown.
Binary file modified img/build-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/build-webgl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/export-asset-package.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/exporting-asset-package.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/webgl-template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 25351ba

Please sign in to comment.