📜 ⬆️ ⬇️

HTML in Unity3D or how to cross a hedgehog with a snake

Sometimes, game developers are faced with non-trivial tasks. Such a task could be, for example, the need to show the user a regular web page on the unity3d game engine, which undoubtedly boasts many integrated technologies, but HTML is not included in this list. I must say right away that there is no “Silver Bullet” ... or not yet. It depends on your degree of optimism.

First of all, you need to determine the goals for which you need HTML: text design using basic tags, creating a user interface using HTML, formatting a reference section (for example, in-game encyclopedia), displaying a static web page or general integration of a full-featured web browser. Accordingly, plug-ins or HTML engines are divided according to the number of tags supported, animation support, implementation technologies (OnGUI or textures), GUI integration (OnGUI or NGUI), support for CSS, HTML5, JavaScript, implementation technology for working with images, etc.

In fact, the choice of HTML plug-ins is quite poor. I found only 5 representatives.

Let's begin our acquaintance with perhaps the most unsightly option:
')

1. HTML Engine for NGUI & Unity GUI for $ 25


Screenshots on the cut:








The screens above show plugin functionality that supports various styles and text effects. However, no CSS, JS, HTML5 or access to web pages.
Pros:

Minuses:


2. PowerUI - $ 60 HTML / CSS


Screenshots on the cut:










Developer site.
Good plugin. In addition to supporting many tags and CSS is also well optimized.
Easily integrates simple html pages into a project.
It is enough to make simple preparatory actions:
1. Add a new layer named: PowerUI.
2. Make sure the other cameras do not see this layer.
3. Create a new object and add the Powerui Manager script to it.
4. Adjust the images (all pictures should be stored in the Resources folder, the type should be Advanced in their properties, “Non Power of 2” should be changed to none, check the read / write enabled checkbox and remove the checkbox with generate mipmaps)
image

Now it is enough to assign your web page to the public field of the created object.

Pros:

Minuses:


3. GUI Design HTML CSS for $ 30


Screenshots on the cut:





Good plugin for GUI design.
Brief demonstration:

Pros:

Minuses:

4. HuG: Hugging HTML on Unity for $ 45


Screenshots on the cut:








A good plugin, but with its flaws. Developer site.
Pros:

Minuses:

5. U3DXT iOS SDK Pro for $ 100


Screenshots on the cut:
Since Since this plugin is very multi-functional, I only attach one screen made in my own application that demonstrates the quality of the web. The blue bar at the top is part of the NGUI interface, and below is the browser viewport.

If all previous plugins tried to implement the HTML interpreter using Unity3D technologies, then these developers went the way of providing full access to the iOS SDK. Those. instead of inventing a bicycle, they simply give access to what the Cupertino developers have already written. Thanks to this, in unity you can easily access any Internet site.
And accessing a web browser is just one of the functions here. In addition, there is access to Inn-app, social plugin, face recognition, speech synthesizer and much more. In general, this SDK is worthy of a separate article, and is able to press, for example, Prime31.
Such a solution, by itself, has a reverse side, namely, applicability only to iOS builds.
Pros:

Minuses:


The review is, of course, quite superficial, but I hope it will be useful for developers who have come across a similar task for the first time. Now you will understand where to dig.

Source: https://habr.com/ru/post/220183/


All Articles