Help us understand the problem. What is going on with this article?

【Unity】【WebGL】WebGLプレイヤーをブラウザ全体に表示したい

More than 1 year has passed since last update.

環境

Unity2017.4.3f1
Chrome(66.0.3359.181)

やりたいこと

ss1.png

↑これを

↓こうしたい

ss2.png

index.htmlとstyle.cssを変更する

index.html中のgameContainerからstyleを削除する

<!-- <div id="gameContainer" style="width: 960px; height: 600px"></div> -->
<div id="gameContainer"></div>

TemplateData/style.cssに以下の2行を加える

html,body,div { margin: 0; padding: 0; width: 100%; height: 100%;}
canvas { margin: 0 0 0 0; position: absolute; z-index: 9; width: 100%; height: 100%;}

以上。

ビルドするごとに毎回変更するの?

UnityのWebGLテンプレート機能を使えば、毎回手直しする必要は無い

今回の例なら、以下の2つのファイルを置いておけば良い

  • Assets/WebGLTemplates/{TEMPLATE_NAME}/index.html
  • Assets/WebGLTemplates/{TEMPLATE_NAME}/TemplateData/style.css

WebGLのPlayerSettingsのテンプレート選択項目に新しいテンプレートが追加されるので、それを選択してビルドする

ss3.png

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした