Code Monkey home page Code Monkey logo

awesomiumunity's Introduction

AwesomiumUnity

AwesomiumUnity is a third-party Awesomium wrapper intended for use with Unity3D.

AwesomiumUnity allows you to display and use HTML documents in your Unity3D application. HTML5, CSS, and JavaScript are supported, and rendered views can be displayed anywhere a regular Unity Texture2D can be used. Possibilities for your application include:

  • Fully interactive live browsing of the internet, in-game.
  • Rich, complex 2D or 3D UI's created using HTML, CSS, and JavaScript.
  • Quick iteration times and result. Just edit your HTML, CSS, or JavaScript and reload!
  • Fully functional in the Unity Editor. Don't restrict yourself to just a standalone game!

The wrapper consist of a custom native code C++ DLL which simply wraps Awesomium's C++ API (requires Unity Pro to use) and a set of C# scripts that interface with this DLL.

The current state of the project is:

Stable, the majority of important features implemented. Other functionality in development, code structure and architecture not completely final.

Projects using AwesomiumUnity

Besides individual users, AwesomiumUnity is also used by some game developers or other companies to integrate the power of HTML5 and web browsing in their application.

The developers of TableTop Simulator by Berserk Games are using AwesomiumUnity in their game for an in-game tablet in the 3D game world, which users can interact with and use to browse the web.

Folders

CppDLL

This folder contains a MSVC solution for the C++ DLL that wraps the Awesomium C++ API. To compile this solution you need to:

  • Have the Awesomium SDK installed. If you install it somewhere other than C:\Program Files (x86)\Awesomium Technologies LLC\Awesomium SDK\1.7.5.0, you will have to change the project's include directory (currently set to C:\Program Files (x86)\Awesomium Technologies LLC\Awesomium SDK\1.7.5.0\include) and the library directory (currently set to C:\Program Files (x86)\Awesomium Technologies LLC\Awesomium SDK\1.7.5.0\build\lib).
  • Have OpenGL installed (The project links with 'opengl32.lib').
  • Have the DirectX SDK installed and "DXSDK_DIR" as an environment variable (the project's include directories currently have $(DXSDK_DIR)\include set).

If succesfully built, the output will be located at either:

  • CppDLL\bin\Debug\AwesomiumUnity.dll

or

  • CppDLL\bin\Release\AwesomiumUnity.dll

AwesomiumUnityScripts

This folder contains the Unity scripts that interact with the native code (C++) DLL and the scripts that are actually attached to components in order to get webpages to render.

The files serve the following purposes:

  • AwesomiumUnityScripts\AwesomiumUnityError.cs :
    • Provides a binary-compatible structure to represent Awesomium errors.
  • AwesomiumUnityScripts\AwesomiumUnityVirtualKey.cs :
    • Provides a binary-compatible structure to represent Awesomium virtual keys.
  • AwesomiumUnityScripts\AwesomiumUnityWebCore.cs :
    • Provides a class with static functions that interface with the C++ DLL. This class is used for talking to the Awesomium::WebCore C++ class. Initialization and shutdown of the WebCore is handled automatically when needed.
  • AwesomiumUnityScripts\AwesomiumUnityWebCoreHelper.cs :
    • Contains a class that derives from MonoBehaviour which is created automatically and updates the WebCore each frame.
  • AwesomiumUnityScripts\AwesomiumUnityWebKeyboardEvent :
    • Provides a binary-compatible structure to represent Awesomium's _WebKeyboardEvent_s.
  • AwesomiumUnityScripts\AwesomiumUnityWebKeyModifiers :
    • Provides a binary-compatible structure to represent Awesomium's WebKeyModifiers.
  • AwesomiumUnityScripts\AwesomiumUnityWebKeyType :
    • Provides a binary-compatible structure to represent Awesomium's WebKeyType.
  • AwesomiumUnityScripts\AwesomiumUnityWebView :
    • Provides a class that interfaces with the C++ DLL. This class is used for talking to instances of the Awesomium::WebView C++ class.
  • AwesomiumUnityScripts\AwesomiumUnityWebTexture :
    • Contains the main class you need to use to render webpages. The class derives from MonoBehaviour and should be attached to a GameObject. A single instance of this class represent a single webpage. Input, interactiveness, etc. are all handled by this class. Note that this class acts as a wrapper to a WebView and can serve as an example of how you could implement such logic yourself. The WebTexture utilizes the WebView's API to control the view.
  • AwesomiumUnityScripts\AwesomiumUnityWebSession.cs :
    • Provides an interface and data to customize certain settings that influence the session. Settings include things as switching on or off web audio, WebGL, HTML5 local storage, JavaScript, plugins (such as Flash), but also whether the session cache should be stored in memory or on disk, and in what exact location.

AwesomiumUnityScripts\Examples

This folder contains simple examples to get you going. In most cases you can simply add one of these example scripts to a GameObject that has been set up to render webpages to see it working.

If an example is accompanied by a folder with the same name as the example script, it means that there is some HTML/CSS/JavaScript code that goes with it. These are generally loaded directly off of GitHub from within the example script.

Using AwesomiumUnity

Getting it to work in the Unity Editor

Note: Due to limitations of Awesomium, AwesomiumUnity requires a 32-bit Unity editor. The 32-bit Unity editor can be selected and downloaded through a dropdown list on the Unity download page.

  • Do one of the following two options:
      1. Copy the pre-built AwesomiumUnity.dll file from either CppDLL\bin\Debug or CppDLL\bin\Release to your Unity project's Assets\Plugins folder. OR
      1. Build the MSVC project and copy the resulting .DLL file (AwesomiumUnity.dll) to your Unity project's Assets\Plugins folder.
  • Copy the following files from your Awesomium SDK installation directory's build\bin folder to your Unity installation directory's Editor folder (NOT your project Assets\Editor folder!).
    • awesomium_process.exe
    • awesomium.dll
    • icudt.dll
    • libEGL.dll
    • libGLESv2.dll
    • xinput9_1_0.dll
    • avcodec-53.dll
    • avformat-53.dll
    • avutil-51.dll
  • Copy the folder AwesomiumUnityScripts to your Unity project's Assets folder (or any subdirectory within it).
  • Open your Unity project
  • Create a GameObject
  • Add either a GUITexture component or a Renderer component with a material and a MeshCollider component to your GameObject
  • Add the AwesomiumUnityWebTexture component to your GameObject
  • Hit play

Getting it to work for a standalone .exe

Note: Due to limitations of Awesomium, AwesomiumUnity requires a 32-bit application (built with a 32-bit editor). The 32-bit Unity editor can be selected and downloaded through a dropdown list on the Unity download page.

  • Do one of the following two options:
      1. Copy the pre-built AwesomiumUnity.dll file from either CppDLL\bin\Debug or CppDLL\bin\Release to the same folder as your executable. OR
      1. Build the MSVC project and copy the resulting .DLL file (AwesomiumUnity.dll) to the same folder as your executable.
  • Copy the following files from your Awesomium SDK installation directory's build\bin folder to the same folder as your executable.
    • awesomium_process.exe
    • awesomium.dll
    • icudt.dll
    • libEGL.dll
    • libGLESv2.dll
    • xinput9_1_0.dll
    • avcodec-53.dll
    • avformat-53.dll
    • avutil-51.dll
  • Copy the folder AwesomiumUnityScripts to your Unity project's Assets folder (or any subdirectory within it).
  • Open your Unity project
  • Create a GameObject
  • Add either a GUITexture component or a Renderer component with a material and a MeshCollider component to your GameObject
  • Add the AwesomiumUnityWebTexture component to your GameObject
  • Build an executable (NOTE: You'll probably have to have AwesomiumUnity.dll in your Assets\Plugins folder as well before the build process will succeed).

External Links

awesomiumunity's People

Contributors

bkeiren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

awesomiumunity's Issues

GOT DOWNLOAD TO WORK!

Added DownloadListener.h and DownloadListener.cpp, and made appropriate changes in both the exporting (c++ scripts) and importing (c# scripts) sides. I'm so excited about this! Finally seeing a file download almost made me cry! lol I am REALLY looking forward to cleaning my stuff up and adding it to your MASTERPIECE alongside the uGUI implementation (the new Unity UI) here on Github.

Just letting you know of this to remind you that this treasure is VERY FAR from being out-dated/dead! Sorry it had to be in the issues. :P

(Working with your code is SO awesome BTW. It's like one of those special snowflakes you rarely find! I envy your co-workers). :P

Opening new tabs (using ShowCreatedWebView event)

Hey!
As the title says, I am trying to implement new-tab behavior in my application. Until now any new link opens in the same webview. I would like to handle new tabs generated from either: _target=”blank”, _target=”new”, window.open, or by manually triggering new tab behavior just like right clicking and opening a new tab in Chrome or Firefox (perhaps by manually calling TriggerShowCreatedWebView in AwesomiumUnityWebView.cs or maybe executing JS function window.open).

Am I on the right track? Is this the right way to do it? (Awesomium-wise not Unity-wise) Any further details and directions are highly appreciable.

Unity3D: Not working at all

Has anyone been able to get anything working at all with this recently? I am simply getting black textures and nothing happens (for example WebTextures, with the script component attached).

I am using Unity 5 on Windows 7 64bit.

Universal Windows Apps

Hi,

have you tested this with a UWA? I'm seeing Win32 errors occuring when I try and execute and the texture remains blank.

You can test yourself in 5 minutes:

I followed the basic instructions you provided using a basic Plane and attached the WebRenderer and WebCore scripts. This works fine in the Unity Editor.

Change platform to Windows Store and set to Windows Universal 10 / Any Device / D3D / Local Machine.
Build and open generated project in VS2015.
Build works fine but trying to run / debug results in an Unhandled Win32 exception occured.

After manually attaching the UnityPlayer_UAP_x86_debug_dotnet.pdb and rerunning it appears to be dying in win32threads.cpp (Stack trace belpw):

stacktrace


Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention

Event Log Data:

Faulting application name: WebBrowser.exe, version: 0.0.0.0, time stamp: 0x56c6997e
Faulting module name: UnityPlayer.dll, version: 5.5.0.0, time stamp: 0x58371462
Exception code: 0x4000001f
Fault offset: 0x03d2a65c
Faulting process id: 0x367c
Faulting application start time: 0x01d26c57a96aca07
Faulting application path: C:\Dev\Hololens\Testing\WebBrowser\WindowsUniversalApp\WebBrowser\bin\x86\Debug\AppX\WebBrowser.exe
Faulting module path: C:\Dev\Hololens\Testing\WebBrowser\WindowsUniversalApp\WebBrowser\bin\x86\Debug\AppX\UnityPlayer.dll
Report Id: 04632150-9880-42d8-94c7-8feaaae43de4
Faulting package full name: WebBrowser_1.0.0.0_x86__pzq3xp76mxafg
Faulting package-relative application ID: App

Thank You,

Greg

WebGL Support

Hello,

i have problems running WebGL. This site tells me it is not supported. Can you elaborate on the state of WebGL?

Thank you.

Update the readme.

Please add to the usage instructions in readme to set the position of the gameobject to (0.5, 0.5, 0) and scale to 1. I have just spend an hour trying to figure out why I can't see anything on the screen.

And add that a 32-bit unity editor is needed and can be downloaded from the dropdown menu on the download page http://i.imgur.com/Z62HjCC.png

Cheers.

login button and text selection problems

I discovered a Unity specific issue with this implementation. The Shift works as a modifier for keys getting to upper case etc, but does not register on it's own as a Keypress / Keyrelease (i'm using unity 5.0.1f1 & the newest awesomium w/ this plugin).

Solved by adding an input hook on update that registers it's own versions of injected keypress/release for AwesomiumUnityVirtualKey.LSHIFT;

Thanks for your great work on this wrapper!

Is it possible to change the useragent for webview?

Hi,
this is great tool. However, one thing im trying and did not accomplish is that as you can see, right now the tool is using chrome 18. However, is it possible to initialize webcore with newer version of chrome, or just another browser?

Move to 64-bit

Awesomium say in the next build they will support 64-bit operating systems. If you're still maintaining this it would be awesome(ium) if you upgraded this plugin to support 64-bit Unity!
Just a heads up.

Cross Domain / Loading from file://

Hi,

I'm using Angular.js to manage my game UI, but have not been able to work out how to enable cross-domain XMLHTTP requests for loading in view templates.

I have set WebSecurity = false in my websession settings, which from the code comments looked like it would allow file:// access, but I still get cross domain requests blocked.

Awesomium win-forms has a FileAccessFromFileURL property that can be set to allow this.

Is there something that I need to do in the cpp project and re-compile?

Thanks,
Lars

DllNotFoundException: AwesomiumUnity

Hi! We're excited about the prospects of this integration, but we're facing an issue.

Despite putting the AwesomiumUnity.dll file in the Assets/Plugins/ folder -- we've tested both the pre-build dlls provided by this package -- we're getting the following error with the example webtexture script when we try running the game. Any ideas why?

DllNotFoundException: AwesomiumUnity
AwesomiumUnityWebCore.get_IsRunning () (at Assets/AwesomiumUnityScripts/AwesomiumUnityWebCore.cs:140)
AwesomiumUnityWebCore.EnsureInitialized () (at Assets/AwesomiumUnityScripts/AwesomiumUnityWebCore.cs:146)
AwesomiumUnityWebTexture.Initialize () (at Assets/AwesomiumUnityScripts/AwesomiumUnityWebTexture.cs:71)
AwesomiumUnityWebTexture.Start () (at Assets/AwesomiumUnityScripts/AwesomiumUnityWebTexture.cs:99)

Awesomium 1.7.5.0
Unity 4.6.2f1 Pro
Windows 7 x64 (Admin acccount)

License?

Hi all,
What license is this project released under? It's convention to have a LICENSE file, with the MIT/BSD/whatever text in there.

Webtexture with Canvas Renderer & AwesomiumUnity.DLL

Hey @bkeiren , thank you so much for this awesome refactored wrapper and for the decent features you implemented. Your instructions in README.MD led to a successful attempt of integrating Awesomium with Unity using your awesome wrapper on my 64-bit windows 7 and 32-bit Unity 5.1.

Though I would like to ask you the following things:
-1. Would kindly allow integration of AwesomiumUnityWebTexture.CS component with Canvas Renderer? I can only use either two methods: (Plane or any object with mesh renderer, material and collider OR deprecated GUITexture) I tried changing AwesomiumUnityWebTexture.CS, namely "void Initalize()", by creating a sprite using Texture2D attribute "m_texture" and assigning that sprite to Image component in a Canvas-child-object but that didn't work properly; image was uninteractive(it did view the page though). Perhaps I should also change OnMouseDown()?

EDIT: webpage is indeed loadable after making changes to both "Initialize()" and "OnMouseDown()", but uninteractive.
Here's the code for AwesomiumUnityWebTexture.Initialize() & AwesomiumUnityWebTexture.OnMouseDown()

    public void Initialize()
    {
    m_HasBeenInitialized = true;

    AwesomiumUnityWebCore.EnsureInitialized();

    // Call resize which will create a texture and a webview for us if they do not exist yet at this point.
    Resize(m_Width, m_Height);
    var h = GetComponent<Image>();

    if (h)
    {
        var piv = GetComponent<RectTransform>().pivot;
        var myRect = new Rect();//GetComponent<RectTransform>().rect; produces a an error (current bug in unity 5.1.1f1)
        myRect.x = myRect.y = 0;
        myRect.width = m_Texture.width;
        myRect.height = m_Texture.height;
        var img = GetComponent<Image>();
        img.sprite = Sprite.Create(m_Texture, myRect, piv);
    }
    }
    //------------------------------------------OnMouseOver()------------------------------------------
    void OnMouseOver()
    {
    if (!m_Interactive) return;

    if (m_WebView != null /*&& !m_WebView.IsLoading*/)
    {
        //!--Maj
        var img = GetComponent<Image>();
        if (img)
        {
            float rectWidth =  img.rectTransform.rect.width;
            float rectHeight =  img.rectTransform.rect.height;
            float rectX =  img.rectTransform.rect.x;
            float rectY =  img.rectTransform.rect.y;

            int MouseX = (int)Input.mousePosition.x;
            int MouseY = Screen.height - (int)Input.mousePosition.y;

            MouseX = (int)(((MouseX - rectX) / rectWidth) * m_Width);
            MouseY = (int)(((MouseY - rectY) / rectHeight) * m_Height);

            m_WebView.InjectMouseMove(MouseX, MouseY);

        }
    }
    }

-2. Is it possible we view AwesomiumUnity.DLL? I couldn't decompile it since it's unmanaged C++ code. If it's a no then that is totally fine.

Again thank you so much for the hard work! I really hope you see this. I know you are really preoccupied but I believe in the potential of Awesomium and delighted with the easily understandable wrapper you wrote.

Crashes

I just tried your Awesomium wrapper for Unity 4.5. Unfortunately, the Unity is crashing when I try to play.

Can you provide any support of your plugin/package or guide Awesomium-Unity integration.

Works perfect in editor, but can't show texture on a plane in standalone exe

I use Unity 5.4.4 32bits
no error in output log
I put all the dll in the build plugins folder
The exe can't show the texture of the website but it can do all the function of the website
ie: I go to a youtube website, you can hear the sound and pause it but nothing show
I don't even change a word of AwesomiumUnityWebTexture code
Do I miss some requirement of a standalone exe?

It just like I run in editor mode without AwesomiumUnity.dll.
But I put AwesomiumUnity.dll file in plugin folder under asset before I build.

Cannot See Page

Using the sample code,i still cannot view page through texture

Can you create example project? Still DllNotFoundException: Assets/Plugins/x86/AwesomiumUnity.dll

I have same problem with DllNotFoundException. And please, create example project. Thank you
DllNotFoundException: Assets/Plugins/x86/AwesomiumUnity.dll
AwesomiumUnityWebCore.get_IsRunning () (at Assets/AwesomiumUnityScripts/AwesomiumUnityWebCore.cs:140)
AwesomiumUnityWebCore.EnsureInitialized () (at Assets/AwesomiumUnityScripts/AwesomiumUnityWebCore.cs:146)
AwesomiumUnityWebTexture.Initialize () (at Assets/AwesomiumUnityScripts/AwesomiumUnityWebTexture.cs:71)
AwesomiumUnityWebTexture.Start () (at Assets/AwesomiumUnityScripts/AwesomiumUnityWebTexture.cs:99)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.