Created
April 3, 2022 13:55
-
-
Save unitycoder/da17fe8f0fed3095e38f736b787bcdf6 to your computer and use it in GitHub Desktop.
webgl get onfocus onblur events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class WEBCONNECTOR : MonoBehaviour | |
| { | |
| void Start() | |
| { | |
| Application.ExternalEval("function onfoc(){GetUnity().SendMessage('WEBCONNECTOR','BrowserFocus','...');}"); | |
| Application.ExternalEval("function onblr(){GetUnity().SendMessage('WEBCONNECTOR','BrowserBlur','...');}"); | |
| Application.ExternalEval("window.onfocus=onfoc;"); | |
| Application.ExternalEval("window.onblur=onblr;"); | |
| Debug.Log("Set"); | |
| } | |
| void BrowserBlur() | |
| { | |
| Debug.Log("Blur"); | |
| } | |
| void BrowserFocus() | |
| { | |
| Debug.Log("Focus"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment