- Home /
How do i open an hmtl file located on my project folder?
All i need to do is open an html file by clicking an object in the scene. I want the html file loads in a browser window. The html file is located on my project folder.
Answer by dreamychris · Apr 05, 2013 at 04:27 AM
Ship the HTML file with the game, as a loose file. You can achieve this by placing it in the StreamingAssets folder.
Figure out the URL to the shipped HTML file and call Application.OpenURL. You can use the special file:// protocol to tell the browser to access the local filesystem. Something like this:
Application.OpenURL("file:///" + Application.streamingAssetsPath + "/readme.html");
Note that this will not work on Android or Web Player builds, for the reasons explained here. For Android, you might consider using the WWW class to retrieve the HTML file from the .apk file and copy it somewhere accessible. For Web Player builds, the simplest solution is to host the HTML file on your web server, and call something like:
Application.OpenURL("http://www.example.com/mygame/readme.html");
(If someone is playing a Web Player build, it's a safe bet they have internet access :) )
Your answer
Follow this Question
Related Questions
Tutorial File Wont Open! 1 Answer
Uploading Unity to Website 1 Answer
Menu button to open a "Open file dialog"? 1 Answer
How to open file csv in localdisk at runtime scene as data resources? 0 Answers