Пример #1
0
    /// <summary>
    /// Called once per frame and mainly checks on the web rendering process status
    /// </summary>
    void Update()
    {
        if (RuntimeError || ProcessError)
        {
            return;
        }

#if UNITY_EDITOR
        if (EditorApplication.isCompiling)
        {
            Debug.Log("Unity is recompiling scripts, play session ended.");
            EditorApplication.ExecuteMenuItem("Edit/Play");
            return;
        }
#endif

#if (!UNITY_IPHONE || UNITY_EDITOR) && !UNITY_WEBPLAYER
        if (!UWKConfig.DebugProcess)
        {
            bool hasExited = process.HasExited;

            if (!restarting && !hasExited && !Plugin.UWK_ProcessResponding())
            {
                unresponsiveTime += Time.deltaTime;
            }
            else
            {
                unresponsiveTime = 0;
            }


            if (!hasExited && unresponsiveTime > 16 && !process.KillAttempted)
            {
                Debug.Log("Killing zombie UWKProcess");

                unresponsiveTime = 0;

                if (UWKProcessZombified != null)
                {
                    UWKProcessZombified();
                }

                UWKView.InvalidateAllViews();

                processUp = false;
                process.KillIt();

                Plugin.ClearCommands();
            }

            else if (hasExited)
            {
                if (hasExited && !restarting)
                {
                    Debug.Log("Process has exited");

                    restarting = true;

                    if (UWKProcessWillRestart != null)
                    {
                        UWKProcessWillRestart();
                    }


                    Plugin.ClearCommands();
                    Plugin.ProcessInbound += processInbound;
                    Plugin.ProcessReturn  += processReturn;

                    process = new Process();

                    bool result = process.Go();

                    if (!result)
                    {
                        Debug.Log("process.Go() == false");
                    }

                    if (result && UWKProcessRestarted != null)
                    {
                        UWKProcessRestarted();
                    }

                    if (result && UWKProcessStarted != null)
                    {
                        UWKProcessStarted();
                    }
                }
            }
        }
#endif

        sInstance.update();
    }