Exemple #1
0
        protected void OnApplicationQuit()
        {
            //According to http://docs.unity3d.com/Manual/ExecutionOrder.html,
            //OnDisable will be called before this. Experience shows this to be not so much the case.
            //Therefore, we will forcefully call OnDestroy()
            OnDestroy();

            if (BrowserNative.zfb_numBrowsers() == 0)
            {
                //last one out, turn off the lights

                //beforeunload windows won't fully disappear without ticking the message loop
                //Ideally, we'd just keep ticking it, but we are stopping.
                for (int i = 0; i < 10; ++i)
                {
                    BrowserNative.zfb_tick();
                    System.Threading.Thread.Sleep(10);
                }


                        #if UNITY_EDITOR
                //You can't re-init CEF, so if we are the editor, never shut it down.
                        #else
                BrowserNative.UnloadNative();
                        #endif
            }
        }
        private static void CheckForEditorExit()
        {
            //Read off the last bit of log to see if we are going to reload or exit.
            //NB: Doing Debug.Log in this function before the read will result in a read of that log instead.
            const string exitString = "Cleanup mono";
            const int    readBack   = 500;
            var          buffer     = new byte[readBack];

            try {
                using (var file = File.Open(logLocation, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) {
                    file.Seek(-readBack, SeekOrigin.End);

                    var len = file.Read(buffer, 0, readBack);

                    var readStr = System.Text.Encoding.UTF8.GetString(buffer, 0, len);
//				Debug.Log("len " + len + " readstr " + readStr);

                    if (readStr.Contains(exitString))
                    {
                        Debug.Log("Editor shutting down, also stopping ZFBrowser");


                        BrowserNative.UnloadNative();
                    }
                }
            } catch (Exception ex) {
                Debug.LogError("Failed to check for shutdown: " + ex);
            }
        }
 public void OnApplicationQuit()
 {
     BrowserNative.UnloadNative();
 }
 public void OnApplicationQuit()
 {
     BrowserNative.DestroyAllBrowsers();
     BrowserNative.UnloadNative();
 }