Пример #1
0
    public void load(string url)
    {
        if (View == null)
        {
            isLoaded = false;
            // Create the WebView, note that smart rects are disabled as they are only supported on 2D surfaces
            View = UWKCore.CreateView("WebTextureExample", url, Width, Height, true);

            // setup out delegate for when the view has veen created and ready to go
            View.ViewCreated += viewCreated;
        }
        else
        {
            Valid    = true;
            isLoaded = true;
        }

        // listen in for loaded page if we have a URL
        if (url != null && url.Length > 0)
        {
            Debug.Log("????!!!!!!!!!!!!!!!!???");
            View.LoadFinished += loadFinished;
        }
        else if (HtmlText != null)
        {
            // for TextAsset example, we won't render object until the view is loaded
            gameObject.renderer.enabled = false;
        }
    }
Пример #2
0
    public void load(string url)
    {
        if (View == null) {

            isLoaded = false;
            // Create the WebView, note that smart rects are disabled as they are only supported on 2D surfaces
            View = UWKCore.CreateView ("WebTextureExample", url, Width, Height, true);

            // setup out delegate for when the view has veen created and ready to go
            View.ViewCreated += viewCreated;
        } else {
            Valid = true;
            isLoaded = true;
        }

        // listen in for loaded page if we have a URL
        if (url != null && url.Length > 0) {

            Debug.Log("????!!!!!!!!!!!!!!!!???");
            View.LoadFinished += loadFinished;
        }
        else if (HtmlText != null)
            // for TextAsset example, we won't render object until the view is loaded
            gameObject.renderer.enabled = false;
    }
Пример #3
0
 /// <summary>
 /// Restarts all existing views, once the UWKProcess has restarted
 /// </summary>
 public static void RestartAllViews()
 {
     UWKView[] views = UWKView.FindObjectsOfType(typeof(UWKView)) as UWKView[];
     foreach (UWKView v in views)
     {
         v.restart();
     }
 }
Пример #4
0
 /// <summary>
 /// Invalidates all views, generally in the response to an issue with a UWKProcess restart
 /// </summary>
 public static void InvalidateAllViews()
 {
     UWKView[] views = UWKView.FindObjectsOfType(typeof(UWKView)) as UWKView[];
     foreach (UWKView v in views)
     {
         v.invalidate();
     }
 }
Пример #5
0
    void loadFinished(UWKView view)
    {
        Debug.Log("nonononononononononono");
        //gameObject.renderer.enabled = true;

#if UNITY_IPHONE && !UNITY_EDITOR
        view.captureTexture();
#endif
        isLoaded = true;
    }
Пример #6
0
    void loadFinished(UWKView view)
    {
        Debug.Log("nonononononononononono");
        //gameObject.renderer.enabled = true;

        #if UNITY_IPHONE && !UNITY_EDITOR
        view.captureTexture();
        #endif
        isLoaded = true;
    }
Пример #7
0
    //void On

    /*void OnGUI ()
     * {
     *      if (!Valid)
     *              return;
     *
     *      if (!KeyboardEnabled)
     *              return;
     *
     *      View.ProcessKeyboard (Event.current);
     *
     * }
     */
    // Delegate for initializing one view has been created
    void viewCreated(UWKView view)
    {
        Valid = true;

        view.AlphaMask = AlphaMask;

        if (HtmlText != null)
        {
            view.LoadTextAssetHTML(HtmlText);
            View.LoadFinished += loadFinished;
        }
    }
Пример #8
0
    /// <summary>
    /// Remove a UWKView from the core
    /// </summary>
    public static void RemoveView(UWKView view)
    {
        if (sInstance == null)
        {
            return;
        }

        if (GetView(view.Name) == null)
        {
            return;
        }

        viewLookup.Remove(view.Name);
        view.Remove();
    }
Пример #9
0
    private static void CreateJSPopup(string name, int width, int height)
    {
        UWKView view = CreateViewInternal(name, width, height, true);

        view.JSPopup = true;

        GameObject go = new GameObject("UWKPopup_" + name);

        UnityEngine.Object.DontDestroyOnLoad(go);

        UWKPopup p = go.AddComponent <UWKPopup> ();

        p.View = view;

        popups [name] = p;
    }
Пример #10
0
    void boot(ref Command cmd)
    {
        //Debug.Log("WebKit version: " + cmd.GetSParam (0));
        //Debug.Log("Qt version: " + cmd.GetSParam (1));

        ProductKey = cmd.GetSParam(2);

        int error = cmd.iParams [0];

        ProductTrial = cmd.iParams [3] == 1 ? true : false;

        if (error != 0)
        {
            Debug.Log("Error starting uWebKit");
        }

        if (cmd.iParams [2] == 2)
        {
            //need to activate
                        #if UNITY_EDITOR
            if (!EditorApplication.currentScene.Contains("UWKActivationScene"))
            {
                EditorUtility.DisplayDialog("uWebKit Activation Required", "Please select uWebKit/Activate from the Editor menu", "Ok");
                EditorApplication.ExecuteMenuItem("Edit/Play");
            }
                        #endif
        }

        if (cmd.iParams [1] == 0)
        {
            StandardVersion = true;
        }

        processUp = true;

        if (restarting)
        {
            restarting = false;
            UWKView.RestartAllViews();
        }

        booted = true;

                #if UNITY_EDITOR
        if (StandardVersion)
        {
            if (GetNumViews() > 1)
            {
                EditorUtility.DisplayDialog("uWebKit Standard Version", "uWebKit Pro required for multiple web views", "Ok");
            }
        }
                #endif


        // enable all views created before boot
        foreach (UWKView view in viewLookup.Values)
        {
            view.enabled = true;
        }

        cmd = Command.NewCommand("ALWP", AllowJavascriptPopups ? 1 : 0);
        cmd.Post();

        // set proxy if any
        if (UWKConfig.ProxyEnabled)
        {
            if (UWKConfig.ProxyHostname.Length > 0)
            {
                cmd            = Command.NewCommand("PRXY");
                cmd.numSParams = 1;
                cmd.SetSParam(0, UWKConfig.ProxyHostname);

                cmd.numIParams  = 1;
                cmd.iParams [0] = UWKConfig.ProxyPort;

                if (UWKConfig.ProxyUsername.Length > 0)
                {
                    cmd.SetSParam(cmd.numSParams++, UWKConfig.ProxyUsername);

                    if (UWKConfig.ProxyPassword.Length > 0)
                    {
                        cmd.SetSParam(cmd.numSParams++, UWKConfig.ProxyPassword);
                    }
                }

                // post proxy info
                cmd.Post();
            }
        }

        // set auth if any
        if (UWKConfig.AuthEnabled && UWKConfig.AuthUsername.Length > 0 && UWKConfig.AuthPassword.Length > 0)
        {
            cmd            = Command.NewCommand("AUTH");
            cmd.numSParams = 2;
            cmd.SetSParam(0, UWKConfig.AuthUsername);
            cmd.SetSParam(1, UWKConfig.AuthPassword);
            cmd.Post();
        }
    }
Пример #11
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();
    }
Пример #12
0
    /// <summary>
    /// Remove a UWKView from the core
    /// </summary>
    public static void RemoveView(UWKView view)
    {
        if (sInstance == null) {
            return;
        }

        if (GetView (view.Name) == null)
            return;

        viewLookup.Remove (view.Name);
        view.Remove ();
    }
Пример #13
0
    //void On
    /*void OnGUI ()
    {
        if (!Valid)
            return;

        if (!KeyboardEnabled)
            return;

        View.ProcessKeyboard (Event.current);

    }
    */
    // Delegate for initializing one view has been created
    void viewCreated(UWKView view)
    {
        Valid = true;

        view.AlphaMask = AlphaMask;

        if (HtmlText != null) {
            view.LoadTextAssetHTML (HtmlText);
            View.LoadFinished += loadFinished;
        }
    }
Пример #14
0
 void Start()
 {
     // Create the view
     View = UWKCore.CreateView ("BasicWebGUI", URL, Width, Height);
 }
Пример #15
0
 void Start()
 {
     // Create the view
     View = UWKCore.CreateView("BasicWebGUI", URL, Width, Height);
 }