Esempio n. 1
0
 public void LoadURL(string url)
 {
     if (m_bInitialized)
     {
         UnityWebCore.LoadURL(m_TextureID, url);
     }
 }
Esempio n. 2
0
 public void Loadfile(string filePath)
 {
     if (m_bInitialized)
     {
         UnityWebCore.LoadFile(m_TextureID, filePath);
     }
 }
    public void handleMouseUp(int id)
    {
        //Debug.Log("MouseUp" );
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
        {
            int x = /*width -*/ (int)(hit.textureCoord.x * width);
            int y = height - (int)(hit.textureCoord.y * height);
            UnityWebCore.MouseUp(view.m_TextureID, id, x, y);
        }
    }
Esempio n. 4
0
    public void Init(int width, int height)
    {
        this.width  = width;
        this.height = height;
        m_texture   = new Texture2D(width, height, TextureFormat.ARGB32, false);


        m_TextureID = m_texture.GetNativeTextureID();

        if (m_bForceOpenGL && !Application.isEditor)
        {
            UnityWebCore.CreateView(m_TextureID, new System.IntPtr(0), width, height, false, 10);
        }
        else
        {
            //Get Color[] (pixels) from texture
            m_pixels = m_texture.GetPixels(0);
            // Create GCHandle - Allocation of m_pixels in memory.
            m_pixelsHandler = GCHandle.Alloc(m_pixels, GCHandleType.Pinned);

            UnityWebCore.CreateView(m_TextureID, m_pixelsHandler.AddrOfPinnedObject(), width, height, true, 10);
        }

        // assign m_texture to this GUITexture texture
        //gameObject.GetComponent<Renderer>().material.mainTexture = m_texture;
        //Sprite sprites = Sprite.Create(m_texture, new Rect(0, 0, m_texture.width, m_texture.height), new Vector2(0.5f, 0.5f));
        //QRImage.sprite = sprites;
        gameObject.GetComponent <RawImage>().texture = m_texture;

        //beginNavigationDelFunc = new UnityWebCore.BeginNavigationDelFunc(this.onBeginNavigationDelFunc);
        //beginLoadingDelFunc = new UnityWebCore.BeginLoadingDelFunc(this.onBeginLoadingDelFunc);
        //finishLoadingDelFunc = new UnityWebCore.FinishLoadingDelFunc(this.onFinishLoadingDelFunc);
        //receiveTitleDelFunc = new UnityWebCore.ReceiveTitleDelFunc(this.onReceiveTitleDelFunc);
        //changeTooltipDelFunc = new UnityWebCore.ChangeTooltipDelFunc(this.onChangeTooltipDelFunc);
        //changeTargetURLDelFunc = new UnityWebCore.ChangeTargetURLDelFunc(this.onChangeTargetURLDelFunc);
        //changeCursorDelFunc = new UnityWebCore.ChangeCursorDelFunc(this.onChangeCursorDelFunc);
        //showControlWindowFunc = new UnityWebCore.JSCallbackDelFunc(this.onShowControlWindow);

        //UnityWebCore.SetBeginNavigationFunc(m_TextureID, beginNavigationDelFunc);
        //UnityWebCore.SetBeginLoadingFunc(m_TextureID, beginLoadingDelFunc);
        //UnityWebCore.SetFinishLoadingFunc(m_TextureID, finishLoadingDelFunc);
        //UnityWebCore.SetReceiveTitleFunc(m_TextureID, receiveTitleDelFunc);
        //UnityWebCore.SetChangeTooltipFunc(m_TextureID, changeTooltipDelFunc);
        //UnityWebCore.SetChangeTargetURLFunc(m_TextureID, changeTargetURLDelFunc);
        //UnityWebCore.SetChangeCursorFunc(m_TextureID, changeCursorDelFunc);
        //UnityWebCore.AddJSCallback(m_TextureID, "showControlWindow", showControlWindowFunc);

        browserEventHandler.setDimensions(width, height);

        m_bInitialized = true;

        browserEventHandler.interactive = true;
    }
    void OnMouseExit()
    {
        // Only when interactive is enabled
        if (!interactive)
        {
            return;
        }

        hovered = false;
        focused = false;

        //Debug.Log("MouseOut");
        UnityWebCore.ApplyCursor(0);

        UnityWebCore.MouseUp(view.m_TextureID, 0, lastX, lastY);
        UnityWebCore.MouseUp(view.m_TextureID, 1, lastX, lastY);
        UnityWebCore.MouseUp(view.m_TextureID, 2, lastX, lastY);
        UnityWebCore.MouseMove(view.m_TextureID, -1, -1);
    }
    void OnMouseOver()
    {
        // Only when interactive is enabled
        if (!interactive)
        {
            return;
        }

        hovered = true;

        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
        {
            int x = /*width -*/ (int)(hit.textureCoord.x * width);
            int y = height - (int)(hit.textureCoord.y * height);
            UnityWebCore.MouseMove(view.m_TextureID, x, y);
            lastX = x;
            lastY = y;

            //UnityWebCore.ApplyCursor(1);
        }
    }
Esempio n. 7
0
    public void Destroy()
    {
        try
        {
            if (m_TextureID != 0)
            {
                UnityWebCore.DestroyView(m_TextureID);
                if (m_pixels != null)
                {
                    m_pixelsHandler.Free();
                }
                Destroy(m_texture);
                GetComponent <UnityWebViewEvents>().interactive = false;
                m_TextureID = 0;

                m_bInitialized = false;
            }
        }
        catch (System.Exception e)
        {
            Debug.Log(e);
        }
    }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        if (m_bInitialized /* && controlWindow.showBrowser*/)
        {
            UnityWebCore.Update();
            if (UnityWebCore.IsDirty(m_TextureID))
            {
                m_texture.SetPixels(m_pixels, 0);
                m_texture.Apply();
            }
        }

        if (browserEventHandler.focused && Input.inputString.Length > 0)
        {
            // Send WM_CHAR message
            for (int i = 0; i < Input.inputString.Length; ++i)
            {
                // Backspace - Remove the last character
                if (Input.inputString[i] == '\b')
                {
                    //Debug.Log("backspace");
                    UnityWebCore.InjectKeyboard(m_TextureID, 0x0100, 0x08, 0);
                    UnityWebCore.InjectKeyboard(m_TextureID, 0x0101, 0x08, 0);
                }
                else if (Input.inputString[i] == '\r' || Input.inputString[i] == '\n')
                {
                    //Debug.Log("enter");
                    UnityWebCore.InjectKeyboard(m_TextureID, 0x0100, 0x0D, 0);
                    UnityWebCore.InjectKeyboard(m_TextureID, 0x0101, 0x0D, 0);
                }
                else
                {
                    UnityWebCore.InjectKeyboard(m_TextureID, 0x0102, Input.inputString[i], 0);
                }
            }
        }

        int dyScroll = (int)Input.GetAxis("Mouse ScrollWheel");

        if (dyScroll != 0)
        {
            //Debug.Log("Mouse Scroll" + dyScroll);
            UnityWebCore.MouseWheel(m_TextureID, dyScroll);
        }

        if (browserEventHandler.hovered)
        {
            if (Input.GetMouseButtonDown(2))
            {
                browserEventHandler.handleMouseDown(1);
            }
            else if (Input.GetMouseButtonDown(1))
            {
                browserEventHandler.handleMouseDown(2);
            }
            else if (Input.GetMouseButtonUp(2))
            {
                browserEventHandler.handleMouseUp(1);
            }
            else if (Input.GetMouseButtonUp(1))
            {
                browserEventHandler.handleMouseUp(2);
            }
        }
    }
Esempio n. 9
0
 void OnApplicationQuit()
 {
     UnityWebCore.DestroyView(m_TextureID);
 }