Flash Player 11.2 introduced the long-awaited mouse lock feature. How can we make use of that feature in Unity Flash games?
Here is an example of a script that will (in fullscreen mode) lock the cursor and enable mouse look. Code (csharp): using UnityEngine; using System.Collections; using UnityEngine.Flash; public class MouseLock : MonoBehaviour { public MonoBehaviour MouseLook; // Use this for initialization void Start () { //Add a fullscreen button to your GUI using Flash display object (I just use a sprite here). ActionScript.Import("flash.display.Sprite"); ActionScript.Import("com.unity.UnityNative"); ActionScript.Import("flash.display.Stage"); ActionScript.Import("flash.events.MouseEvent"); ActionScript.Statement("var spr:Sprite = new Sprite()"); ActionScript.Statement("UnityNative.stage.addChild(spr)"); ActionScript.Statement("spr.graphics.beginFill(0xFF0000)"); ActionScript.Statement("spr.graphics.drawRect(0,0,200,40)"); ActionScript.Statement("spr.graphics.endFill()"); ActionScript.Statement("spr.addEventListener(MouseEvent.CLICK, HandleFullScreenButtonClicked)"); } [NotRenamed] public void HandleFullScreenButtonClicked(object @flashEvent) { ActionScript.Import("com.unity.UnityNative"); ActionScript.Import("flash.display.Stage"); ActionScript.Import("flash.display.StageDisplayState"); var fullScreen = ActionScript.Expression<bool>("UnityNative.stage.displayState == StageDisplayState.FULL_SCREEN"); if (fullScreen) { ActionScript.Statement("UnityNative.stage.mouseLock = false"); ActionScript.Statement("UnityNative.stage.displayState = StageDisplayState.NORMAL"); MouseLook.enabled = false; } else { ActionScript.Statement("UnityNative.stage.displayState = StageDisplayState.FULL_SCREEN"); ActionScript.Statement("UnityNative.stage.mouseLock = true"); MouseLook.enabled = true; } } // Update is called once per frame void Update () { } } Just attach the script to a game object and link up an instance of MouseLook.