c# - how to use unity3d webgl content in a asp.net mvc view? -
i have unity webgl project , asp.net mvc project.
i need show webgl content in view.
the first thing came mind copy content of index.html unity gave me , paste in .cshtml file , change addresses. when incorrect header error pops up.
am doing thing wrong or wrong. should change method entirely?
i added these file extensions web.config
<staticcontent> <!-- unity 5.x --> <remove fileextension=".mem" /> <mimemap fileextension=".mem" mimetype="application/octet-stream" /> <remove fileextension=".data" /> <mimemap fileextension=".data" mimetype="application/octet-stream" /> <remove fileextension=".memgz" /> <mimemap fileextension=".memgz" mimetype="application/octet-stream" /> <remove fileextension=".datagz" /> <mimemap fileextension=".datagz" mimetype="application/octet-stream" /> <remove fileextension=".unity3dgz" /> <mimemap fileextension=".unity3dgz" mimetype="application/octet-stream" /> <remove fileextension=".jsgz" /> <mimemap fileextension=".jsgz" mimetype="application/x-javascript; charset=utf-8" /> </staticcontent>
basically.you copy file references view , of course canvas container code initialises it.
add css style file
@styles.render("~/webgl/templatedata/style.css")
and js file
@scripts.render("~/webgl/templatedata/unityprogress.js");
so you`ll have similar this
@{ viewbag.title = "stage"; @styles.render("~/webgl/templatedata/style.css") @scripts.render("~/webgl/templatedata/unityprogress.js"); @scripts.render("~/webgl/build/unityloader.js"); } <h2>stage</h2> <script> var gameinstance = unityloader.instantiate("gamecontainer", "../webgl/build/builds.json", {onprogress: unityprogress}); </script> <div class="webgl-content"> <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="title">figurines</div> </div> </div>
don`t forget add unityweb mime type web.config
<system.webserver> <staticcontent> <remove fileextension=".unityweb" /> <mimemap fileextension=".unityweb" mimetype="application/octet-stream" /> </staticcontent> </system.webserver>
Comments
Post a Comment