they are working on enabling full screen, currently, you would have to create a flash swf shell for full screen, and the mouse lock does not yet play nicely with unity swf's, they are working on that too, hopefully the next unity update will have both
hi. The next update won't have either yet. I've looked at both things, as they are codependent; we'll have this in sooner rather then later after the next build; however due to some disparity on how unity handles gui and how flash's security sandbox regarding enabling fullscreen works, this will need some workarounds for that on our end. In the mean time, having fullscreen can be done in the next build with a hack-ish workaround, which will give you access to the stage from nested actionscript. From there you could capture events from the stage and invoke fullscreen from those mouse events. When it's out I will show paste the workaround, however, it's not integrated or elegant at all. We are working hard on improving the flash build, but it's still in preview and not at release level yet.
well i can paste the full screen interactive work around, the issue is, i did not bother writing the event from sending flash's movementX and movementY over to the Unity, because i thought the next build would have support for these. perhaps you can persuade the UT team to just add support for those 2 variables, but not actually use them. that would allow any hackish workaround to perform better rather than having to send constant movement variables from flash to unity when the mouse moves.
You can access the Stage in 3.5.2 via UnityNative: Code (csharp): ActionScript.Import("com.unity.UnityNative"); ActionScript.Statement("trace(UnityNative.stage);");
Any update on this? In a click handler I'm doing: ActionScript.Import("com.unity.UnityNative"); ActionScript.Statement("UnityNative.stage.displayState = 'fullScreen'"); ActionScript.Statement("trace(UnityNative.stage.displayState)"); but I'm getting: SecurityError: Error #2152: Full screen mode is not allowed.
Normally, that's a flash error indicating that you don't have the allowFullScreenFlag set in your html. However, I've heard of people having issues with this on Flash 11.3 (in general, not just unity-flash). What version are you trying to run this on? Does your html have this flag ?
allowScriptAccess and allowFullScreen are both true (the wrapper is the one that Unity generates from the Flash build, which defaults them to true). The version I'm targeting is 11.2; my Flash player version is 11.2.202.235. From what I understand the full screen requesting code has to exist directly within the mouse or key handler in the ActionScript layer; looking at the generated code it seems as if this is not the case?
@ryamldess; yes indeed, you'll need to invoke the fullscreen using the flash wrapper; you can for example detect a click on stage on there and see if the point falls within a rect. For now this is the only way to do this, we'll have it fixed in the release.
@Anna, you can modify the preloader example to do this. You'll need to make the following changes to the AS3 source: - the UnityLoaderParams supplied to the UnityContentLoader will need to have the first parameter (scaleToStage) set to true. - add an event listener (e.g. KeyboardEvent, MouseEvent) and when that occurs, set the stage's displayState to StageDisplayState.FULL_SCREEN
I get a sample from the archive and add the necessary code to as3. Unfortunately full screen is not available. This solution works?
Code (csharp): import com.unity.UnityNative; import flash.display.Sprite; import flash.display.Stage; import flash.display.StageDisplayState; import flash.events.MouseEvent; var hitArea:Sprite = new Sprite(); hitArea.graphics.beginFill(0, 0); hitArea.graphics.drawRect(0, 0, 960, 580); UnityNative.stage.addChild(hitArea); hitArea.addEventListener(MouseEvent.CLICK,onClick); function onClick(evt:MouseEvent):void { UnityNative.stage.displayState=StageDisplayState.FULL_SCREEN; }
Hello. Could someone who got this working perhaps give an explanation suitable for Flash newbies on how to get this to work? I think it'd help a lot of people (including me).
I haven't played with this, but I'd say the solution agang0718 posted would be the easiest way to go. And I'd probably implement it inside loader-swf, that then loads the unity created swf. TommiH, have you played with that kind of stuff before? It gives you way better control of the Flash specific stuff, and also makes it easier to tweak the flash-functionality without the need to compile unity-content every time you do some minor changes in it. With that method, you could easily, more or less, just copy-paste the code agang0718 provided. Shouldn't be impossible to create a static class out of that code and use it straight in Unity that way. Using 'inline' AS in unity might be also possible, but could get messy, with the functions at least.
Thanks. I managed to get it working with the ActionScript class. In case someone as clueless as me is reading this, here's the code: Code (csharp): using UnityEngine; using UnityEngine.Flash; public class FullScreenSwitcher : MonoBehaviour { public void Start(){ ActionScript.Import("com.unity.UnityNative"); ActionScript.Import("flash.display.Sprite"); ActionScript.Import("flash.display.Stage"); ActionScript.Import("flash.display.StageDisplayState"); ActionScript.Import("flash.events.MouseEvent"); ActionScript.Statement("var hitArea:Sprite = new Sprite();" + "hitArea.graphics.beginFill(0, 0);" + "hitArea.graphics.drawRect(0, 0, 960, 580);" + "UnityNative.stage.addChild(hitArea);" + "hitArea.addEventListener(MouseEvent.CLICK,onClick);" + "function onClick(evt:MouseEvent):void" + "{" + "UnityNative.stage.displayState=StageDisplayState.FULL_SCREEN;" + "}"); } }
@huang; if you target Flash 11.3 and above you can use StageDisplayState.FULL_SCREEN_INTERACTIVE in stead of StageDisplayState.FULL_SCREEN, which then will send key information. This was a restriction on earlier versions of the Flash Player.
Could someone please explain with an example, perhaps, exactly how this might be implemented? With my limited knowledge, I couldn't follow the solutions posted here. Are these separate scripts in the asset folder? How are they referenced? Thanks. UPDATE: I might have found a working example project here: http://forum.unity3d.com/threads/130401-fullscreen?p=936321&viewfull=1#post936321