Forum

You need to log in to create posts and topics.

Example of displaying HTML string

 

Just to clarify, does your in-world view allow to render a HTML string onto a 2D UI element such as a Canvas or text block? Also, can it be rendered onto a 3D object as a texture, etc?

 

If so, do you have any examples of this?

 

We have HTML strings embedded in a JSON file we need to render in Unity.

 

I tried using your 2D PowerUI control but that does not allow you to position the text? It just messed up my scene in Unity.

I also tried the 3D In-world control but I cannot get that to display anything, it worked once and then vanished, and I cannot get it to display again.

Also, your sample for this just displays the back of a TV set, how do I turn this around to view the front?

Any help would be really appreciated.

Many thanks,

 

David.

Hey David,

If the 3D UI worked before and isn't now, and also the TV example isn't rotating around the TV, then it sounds like you've got an issue with your layers. Try the example scenes in a totally clean project and they should all be working as intended there for you (and there's examples of everything you've mentioned here, as well as some getting started guides which describe things like getting hold of the Document reference in C# so you can e.g. get elements and change the innerHTML).

To fix the layers, open up Unity's "Tags and Layers" manager and make sure you've got a layer called "PowerUI". PowerUI tries to create this layer automatically but it can occasionally not be able to save it depending on everything else in your project. That should make sure it's using the right camera from that point onwards.

Ok thank you for getting back to me.

How do I rotate the TV round? I am new to Unity so not sure how to see the front of the TV? I can view the front in the editor but not when I run it in the game window?

You getting hold of the Document reference link seems to only show how to do this with JS? Is there a C# example?

 

Many thanks,

David.

 

 

I just tried it in a fresh project as you said but its still doing the same, I can only see the back of the TV in the sample?

As I have shown in the attached.

Many thanks,

David.

Uploaded files:
  • Screenshot-2018-05-20-15.50.46.png

I just checked the scene view whilst the project is running and noticed the camera is rotating around the TV but for reason in the game view it is not moving and is just stuck looking at the back of the TV?

The camera preview is also blank, but when I stop the project so is not in run mode anymore the Camera Preview refreshes and shows what is should be. But when run again it goes blank again?

Also, when I stop play mode it refreshes the game window to show what it should do, then when I run it again, goes back to the back of the TV and doesn't move.

 

Is this some sort of issue with Unity not refreshing correctly? Or something wrong with the camera?

Ok just built it for Windows and it works fine there, so its just in the Editor that there is an issue.

Any ideas? 🙂

Thanks!

Good news is that I fixed the TV demo, it was as you said, I needed to add the missing PowerUI layer.

Now I have tried creating my own scene using the inworld control but it appears very pixelated and low res as you can see from the screenshot.

Any ideas?

I set the url to http://www.google.co.uk.

Many thanks,

David

Uploaded files:
  • Screenshot-2018-05-21-11.51.50.png

Great I'm glad that worked - there's a few things that can make it low res like that:

* Check your texture quality settings - PowerUI's output is meshes and textures so it'll be affected by texture quality settings too.

* The 'scale' slider on the WorldUI has the same impact as CSS zoom. Most of the time you'll want it on the default value.

* The WorldUI has a pixel width setting which defines how wide the virtual "screen" is. If that's pretty low then the UI will be rendering in a small texture (which could then be getting stretched).

* If you'd like a WorldUI to be pixel perfect, they have a 'pixel perfect' property which scales the WorldUI so e.g. a 400x200px WorldUI is 400x200px on the real screen. Try experimenting with that setting rather than straight scaling up a UI - similarly there's an "always face the camera" property too which makes it rotate so it's always looking at the main camera. The camera to use can be specified by using the FaceCamera method instead. These two settings are often used together (and the "above head text" example scene uses them both as well).

Hopefully something there helps catch it 🙂

Want the latest updates? Check out the repositories.