uwebkit inside noesis
Posted: 28 Nov 2014, 07:57
So I have uWebKit rendering inside of a noesis imagebrush that is set to a the background of a grid.
Image: http://gyazo.com/dc629f13c68ec8b29ddcac78b6b0901d
I'm trying to figure out how I could pass through my mouse position so I can actually highlight links and scroll down the page and what not.
Below is code that creates the texture that I am setting as the background of the grid and handles all there click through events obviously these wont work in the case of hosting it inside noesis but I am not sure how I would go about passing the right mouse coordinates to the ProcessMouse function. If anyone could help this would be greatly appreciated. uwebkit has a free trial if anyone is willing to help out with this. You can get it here http://uwebkit.com/download/
Image: http://gyazo.com/dc629f13c68ec8b29ddcac78b6b0901d
I'm trying to figure out how I could pass through my mouse position so I can actually highlight links and scroll down the page and what not.
Below is code that creates the texture that I am setting as the background of the grid and handles all there click through events obviously these wont work in the case of hosting it inside noesis but I am not sure how I would go about passing the right mouse coordinates to the ProcessMouse function. If anyone could help this would be greatly appreciated. uwebkit has a free trial if anyone is willing to help out with this. You can get it here http://uwebkit.com/download/
Code: Select all
/******************************************
* uWebKit
* (c) 2014 THUNDERBEAST GAMES, LLC
* http://www.uwebkit.com
* [email protected]
*******************************************/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Basic example of using a UWKWebView on a 3D Unity surface
/// </summary>
// IMPORTANT: Please see the WebGUI.cs example for 2D support
public class WebTexture : MonoBehaviour
{
#region Inspector Fields
public bool KeyboardEnabled = true;
public bool MouseEnabled = true;
public bool Rotate = false;
public bool HasFocus = true;
public bool AlphaMask = false;
#endregion
UWKWebView view;
// Use this for initialization
void Start ()
{
view = gameObject.GetComponent<UWKWebView>();
view.SetAlphaMask(AlphaMask);
if (renderer != null)
renderer.material.mainTexture = view.WebTexture;
if (guiTexture != null)
guiTexture.texture = view.WebTexture;
Noesis.TextureSource ts = new Noesis.TextureSource(view.WebTexture);
UserControls.MainMenu.instance.gridWeb.Background = new Noesis.ImageBrush(ts);
}
// Update is called once per frame
void Update ()
{
if (Rotate)
gameObject.transform.Rotate (0, Time.deltaTime * 4.0f, 0);
if (!MouseEnabled || !HasFocus)
return;
RaycastHit rcast;
if (Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out rcast))
{
/*if (rcast.collider != GetComponent<MeshCollider> ())
return;*/
int x = (int)(rcast.textureCoord.x * (float)view.MaxWidth);
int y = view.MaxHeight - (int)(rcast.textureCoord.y * (float)view.MaxHeight);
Vector3 mousePos = new Vector3();
mousePos.x = x;
mousePos.y = y;
view.ProcessMouse(mousePos);
}
}
void OnGUI ()
{
if (!KeyboardEnabled || !HasFocus)
return;
if (Event.current.isKey)
{
view.ProcessKeyboard(Event.current);
}
}
}