-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/web gl loading and ipfs gateway #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tobias-petrasch
wants to merge
2
commits into
main
Choose a base branch
from
fix/web-gl-loading-and-ipfs-gateway
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,136 +1,143 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en-us"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
| <title>{{{ PRODUCT_NAME }}}</title> | ||
| <style> | ||
| html, | ||
| body { | ||
| background: #000000; | ||
| width: 100%; | ||
| height: 100%; | ||
| overflow: visible; | ||
| padding: 0; | ||
| margin: 0; | ||
| } | ||
|
|
||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
| <title>{{{ PRODUCT_NAME }}}</title> | ||
| <style> | ||
| html, | ||
| body { | ||
| background: '#000'; | ||
| width: 100%; | ||
| height: 100%; | ||
| overflow: visible; | ||
| padding: 0; | ||
| margin: 0; | ||
| } | ||
| div#gameContainer { | ||
| background: transparent !important; | ||
| position: absolute; | ||
| } | ||
|
|
||
| div#gameContainer { | ||
| background: transparent !important; | ||
| position: absolute; | ||
| } | ||
| div#gameContainer canvas { | ||
| position: absolute; | ||
| } | ||
|
|
||
| div#gameContainer canvas { | ||
| position: absolute; | ||
| } | ||
| div#gameContainer canvas[data-pixel-art="true"] { | ||
| position: absolute; | ||
| image-rendering: optimizeSpeed; | ||
| image-rendering: -webkit-crisp-edges; | ||
| image-rendering: -moz-crisp-edges; | ||
| image-rendering: -o-crisp-edges; | ||
| image-rendering: crisp-edges; | ||
| image-rendering: -webkit-optimize-contrast; | ||
| image-rendering: optimize-contrast; | ||
| image-rendering: pixelated; | ||
| -ms-interpolation-mode: nearest-neighbor; | ||
| } | ||
|
|
||
| div#gameContainer canvas[data-pixel-art="true"] { | ||
| position: absolute; | ||
| image-rendering: optimizeSpeed; | ||
| image-rendering: -webkit-crisp-edges; | ||
| image-rendering: -moz-crisp-edges; | ||
| image-rendering: -o-crisp-edges; | ||
| image-rendering: crisp-edges; | ||
| image-rendering: -webkit-optimize-contrast; | ||
| image-rendering: optimize-contrast; | ||
| image-rendering: pixelated; | ||
| -ms-interpolation-mode: nearest-neighbor; | ||
| } | ||
| .button-container { | ||
| z-index: 99999; | ||
| position: absolute; | ||
| left: 0; | ||
| right: 0; | ||
| top: 0; | ||
| bottom: 0; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .button { | ||
| cursor: pointer; | ||
| background: #542e91; | ||
| border: none; | ||
| border-radius: 4px; | ||
| color: white; | ||
| padding: 15px 32px; | ||
| text-align: center; | ||
| text-decoration: none; | ||
| display: inline-block; | ||
| font-size: 16px; | ||
| } | ||
|
|
||
| .button-container { | ||
| z-index: 99999; | ||
| position: absolute; | ||
| left: 0; | ||
| right: 0; | ||
| top: 0; | ||
| bottom: 0; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| text-align: center; | ||
| } | ||
| .button:hover { | ||
| background: #6e46ad; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| .button { | ||
| cursor: pointer; | ||
| background: #542E91; | ||
| border: none; | ||
| border-radius: 4px; | ||
| color: white; | ||
| padding: 15px 32px; | ||
| text-align: center; | ||
| text-decoration: none; | ||
| display: inline-block; | ||
| font-size: 16px; | ||
| } | ||
| <body> | ||
| <div id="gameContainer"> | ||
| <canvas | ||
| id="unity-canvas" | ||
| data-pixel-art="{{{ OPTIMIZE_FOR_PIXEL_ART }}}" | ||
| ></canvas> | ||
| <script src="Build/{{{ LOADER_FILENAME }}}"></script> | ||
| <script> | ||
| var canvas = document.querySelector("#unity-canvas"); | ||
| var config = { | ||
| dataUrl: "Build/{{{ DATA_FILENAME }}}", | ||
| frameworkUrl: "Build/{{{ FRAMEWORK_FILENAME }}}", | ||
| codeUrl: "Build/{{{ CODE_FILENAME }}}", | ||
| memoryUrl: "Build/{{{ MEMORY_FILENAME }}}", | ||
| symbolsUrl: "Build/{{{ SYMBOLS_FILENAME }}}", | ||
| streamingAssetsUrl: "StreamingAssets", | ||
| companyName: "{{{ COMPANY_NAME }}}", | ||
| productName: "{{{ PRODUCT_NAME }}}", | ||
| productVersion: "{{{ PRODUCT_VERSION }}}", | ||
| }; | ||
| var scaleToFit = true; | ||
| function progressHandler(progress) { | ||
| var percent = progress * 100 + "%"; | ||
| canvas.style.background = | ||
| "linear-gradient(to right, white, white " + | ||
| percent + | ||
| ", transparent " + | ||
| percent + | ||
| ", transparent) no-repeat center"; | ||
| canvas.style.backgroundSize = "100% 1rem"; | ||
| } | ||
| function onResize() { | ||
| var container = canvas.parentElement; | ||
| var w = window.innerWidth; | ||
| var h = window.innerHeight; | ||
|
|
||
| .button:hover { | ||
| background: #6e46ad; | ||
| } | ||
| </style> | ||
| </head> | ||
| container.style.width = canvas.style.width = w + "px"; | ||
| container.style.height = canvas.style.height = h + "px"; | ||
| container.style.top = Math.floor((window.innerHeight - h) / 2) + "px"; | ||
| container.style.left = Math.floor((window.innerWidth - w) / 2) + "px"; | ||
| } | ||
|
|
||
| <body> | ||
| <div id="gameContainer"> | ||
| <canvas id="unity-canvas" data-pixel-art="{{{ OPTIMIZE_FOR_PIXEL_ART }}}"></canvas> | ||
| <script src="Build/{{{ LOADER_FILENAME }}}"></script> | ||
| <script> | ||
| var canvas = document.querySelector("#unity-canvas"); | ||
| var config = { | ||
| dataUrl: "Build/{{{ DATA_FILENAME }}}", | ||
| frameworkUrl: "Build/{{{ FRAMEWORK_FILENAME }}}", | ||
| codeUrl: "Build/{{{ CODE_FILENAME }}}", | ||
| memoryUrl: "Build/{{{ MEMORY_FILENAME }}}", | ||
| symbolsUrl: "Build/{{{ SYMBOLS_FILENAME }}}", | ||
| streamingAssetsUrl: "StreamingAssets", | ||
| companyName: "{{{ COMPANY_NAME }}}", | ||
| productName: "{{{ PRODUCT_NAME }}}", | ||
| productVersion: "{{{ PRODUCT_VERSION }}}", | ||
| }; | ||
| var scaleToFit = true; | ||
| function progressHandler(progress) { | ||
| var percent = progress * 100 + '%'; | ||
| canvas.style.background = 'linear-gradient(to right, white, white ' + percent + ', transparent ' + percent + ', transparent) no-repeat center'; | ||
| canvas.style.backgroundSize = '100% 1rem'; | ||
| } | ||
| function onResize() { | ||
| var container = canvas.parentElement; | ||
| var w = window.innerWidth; | ||
| var h = window.innerHeight; | ||
| function loadUI() { | ||
| const container = document.createElement("div"); | ||
| container.className = "button-container"; | ||
|
|
||
| container.style.width = canvas.style.width = w + "px"; | ||
| container.style.height = canvas.style.height = h + "px"; | ||
| container.style.top = Math.floor((window.innerHeight - h) / 2) + "px"; | ||
| container.style.left = Math.floor((window.innerWidth - w) / 2) + "px"; | ||
| } | ||
| const button = document.createElement("button"); | ||
| button.className = "button"; | ||
| button.innerHTML = "Connect your Backpack"; | ||
| button.addEventListener("click", () => { | ||
| window.unityInstance.SendMessage("Bkpk", "FetchAvatars"); | ||
| container.remove(); | ||
| }); | ||
| container.appendChild(button); | ||
| document.body.appendChild(container); | ||
| } | ||
|
|
||
| function loadUI() { | ||
| const container = document.createElement('div') | ||
| container.className = "button-container" | ||
|
|
||
| const button = document.createElement('button') | ||
| button.className = "button" | ||
| button.innerHTML = "Connect your Backpack" | ||
| button.addEventListener('click', () => { | ||
| window.unityInstance.SendMessage("Bkpk", "FetchAvatars") | ||
| container.remove() | ||
| }) | ||
| container.appendChild(button) | ||
| document.body.appendChild(container) | ||
| } | ||
| createUnityInstance(canvas, config, progressHandler).then(function ( | ||
| instance | ||
| ) { | ||
| canvas = instance.Module.canvas; | ||
| window.unityInstance = instance; | ||
| loadUI(); | ||
| onResize(); | ||
| }); | ||
|
|
||
| createUnityInstance(canvas, config, progressHandler).then(function (instance) { | ||
| canvas = instance.Module.canvas; | ||
| window.unityInstance = instance; | ||
| loadUI(); | ||
| onResize(); | ||
| }); | ||
|
|
||
| window.addEventListener('resize', onResize); | ||
| onResize(); | ||
| </script> | ||
| </div> | ||
| </body> | ||
|
|
||
| </html> | ||
| window.addEventListener("resize", onResize); | ||
| onResize(); | ||
| </script> | ||
| </div> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,29 @@ | ||
| # Metaverse Backpack Dressing Room Sample | ||
|
|
||
| Example WebGL Demo of the Metaverse Backpack | ||
|
|
||
| ## Setup | ||
| ## Getting started | ||
|
|
||
| ### Setup | ||
|
|
||
| `$ git clone github.com/metaverse-backpack/unity-dressing-room-sample` | ||
|
|
||
| `$ cd unity-dressing-room-sample` | ||
|
|
||
| `$ git submodule update --init --recursive` | ||
|
|
||
| `$ git submodule update --init --recursive` | ||
| ### Build settings | ||
|
|
||
| Open up the Unity project in the Unity Hub. If there is a popup asking if you want to open the project in safe mode, click on `Ignore`. This is because the project starts with a native build target causing dependencies not to be loaded. Change the Build target to WebGL by choosing `File -> Build Settings...`. Then select `WebGL` in the `Platform` selection panel. Ensure `Scene` is selected under `Scenes in Build`. | ||
|
|
||
| ### Build and run | ||
|
|
||
| Select `File -> Build And Run` to start a unity development web server and run the project in a browser (`http://localhost:51326`). | ||
|
|
||
| ### Additional settings | ||
|
|
||
| The dressing room is authorized via OAuth2 to read from Backpack. You can use the client ID `f596bf0f-1fb9-4826-95e9-3c1e8a90a137` for development purposes. The client ID can be set in `Assets/Scripts/SceneManager.cs`. It's important to use a development client ID as the redirect URI is validated by the server and rejected if not matching with the production deployment webserver. | ||
|
|
||
| ## Engine version | ||
|
|
||
| # Engine version | ||
| [Unity 2020.3.36f](https://unity3d.com/unity/whats-new/2020.3.36) | ||
| [Unity 2021.3.10f1](https://unity3d.com/unity/whats-new/2021.3.10) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tobias-petrasch Unity actually just selects an available port so this isn't consistent. Unfortunately, I don't think there's any way to explicitly set which port this runs on, so we might need to remove those redirect URI check restrictions in the backend temporarily if we want to support that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also use an external http server (e.g., npx http-server) with a fixed port. Instead of running build & run in Unity, we only run the build command. Don't think it makes sense to change the backend.