简体   繁体   中英

Trigger iframe/modal overlay from within WebGL Unity application?

Currently working on a project that requires users to look at websites, we do not want the user to leave the Application's site for obvious reasons and unfortunately it has been said that it is also not really wanted to open a new tab... Thus we were wondering if it is technically possible to trigger a modal/iframe with the website that we can lay on top of the current Unity-Application-Site from within Unity. Obviously we would need to communicate that to javascript, which is possible via.jslib but we do not know how restrictive that is, as we do not really have web-dev experience.

So I would be thankful for some pointers in the right direction!

Greetings!

Check out Unity's documentation on JavaScript interop which allows your Unity game (when built inside WebGL) to interact with the webpage that's hosting it!

https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html

(Specifically, the section entitled "Calling JavaScript functions from Unity scripts")

IFrame is an element of HTML so obviously that doesn't exist inside of Unity. So I assume you're looking for a way to display an HTML page inside of a Unity application. Unfortunately Unity doesn't natively support this, thus, it would be quite difficult. The easiest way to achieve this would probably be through the use of 3rd party assets on the Asset Store. I would recommend searching web viewers on the asset store and finding one that's right for your needs. Otherwise you'll have to retrieve all the HTML content through a WWW class or maybe even some .NET and then find a way to render that as a web page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM