Create Webviews at runtime #177
-
Hi ! I just discovered your package and it's very cool, thank you for sharing it ! However, I have a question, in my current project, I would like to instantiate webviews at runtime by code (for instance WebBrowserBasic). But each webview needs a CommunicationLayer with unique ports and it seems impossible to change the CommunicationLayer at runtime as WebBrowserClient.Init() is an internal method only called inside BaseUwbClientManager.Start(). So for now, I created a few WebBrowserBasic prefabs with unique CommunicationLayer but i'm limited by the number of prefabs created in advance. Is there a solution to create webview directly at runtime ? Thanks in advance ! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
You could just set |
Beta Was this translation helpful? Give feedback.
-
I am also trying to create this view at runtime, but not from an Awake method. How should I go about setting the engine and communication layer. I am just doing something like
|
Beta Was this translation helpful? Give feedback.
-
@Voltstro this gist worked perfectly for us and filled in the rest of the gaps I was dealing with. Thanks again for all your help. |
Beta Was this translation helpful? Give feedback.
You could just set
WebBrowserClient.communicationLayer
to a new dynamically created CommunicationLayer instance. You will probably need to do this in Unity's Awake method.