All,
I have a button. This button launches a local html page. This local page displays correctly when I view my scene in unity (via pressing the play button inside unity).
However, when I build and run my scene outside of unity, the window will not launch.
Do I need to do anything special to launch an external app (such as a browser) when I am running my scene standalone?
What does the button do? Have a snippet of what you are doing?
The button notifies it’s parent controller that it has been clicked, upon being clicked, it does this (borrowed from this forum).
var filePath = String.Format("{0}/index.html",Application.dataPath);
switch(Application.platform) {
case RuntimePlatform.WindowsPlayer:
System.Diagnostics.Process.Start(filePath);
break;
default:
System.Diagnostics.Process.Start(String.Format("open \"{0}\"",filePath));
break;
}
Now, “index.html” contains this code.
<script type="text/javascript">
var WindowObjectReference;
function openRequestedPopup(strUrl, strWindowName)
{
if(WindowObjectReference == null || WindowObjectReference.closed)
{
WindowObjectReference = window.open(strUrl, strWindowName,
"resizable=yes,scrollbars=yes,status=yes");
}
else
{
WindowObjectReference.focus();
};
}
</script>
(...)
[url="http://www.unity3d.com/"]test[/url]</p>
This pops up a web browser window with a simple url. However, when I launch this from a standalone player, the page never launches.
Maybe in the standalone case there is no file at the location where you are pointing at?
Data path on the mac links to inside the Player’s contents folder.
http://unity3d.com/Documentation/ScriptReference/Application-dataPath.html
That very well could be it. I’ll try it and get back with you. Thanks!
Okay, that was the problem. The file was not included in the bundle when it was run standalone. What do I need to set to make sure this file is included in every build I’m doing now? In order to test this, I have had to manually drag the index.html file in to the package.
Also, opening a browser works fine when the screen is windowed. Is it possible to either minimize a fullscreen window, or to bring focus to this new browser window I want to display when I am running my game in fullscreen?
Writing a perl/sh script would do the trick I think.
Is there any way to make it so that if I am in displaying in fullscreen, to minimize this view and display my window?
As it works now, it is opening the window, but since I’m in fullscreen, I can’t see that is actually happening (until I exit out).
Screen.isFullScreen can be used to both check in what mode you are and also be used set to false to switch to window mode:
Screen.isFullScreen = false;
Thank you! That worked great.