set the webview URL dynamically
Is there any method other than using the inspector where I can dynamically set the URL based on certain conditions?
Does this mean you want to change the initialisation URL at runtime?
If so, see here. you need to pass the url argument to the init function.
and you need to create a custom controller class to replace this default controller class.
What if I provide a URL in the following code?
[SerializeField] private string m_url = "https://youtube.com";
@TLabAltoh
What if I provide a URL in the following code?
[SerializeField] private string m_url = "https://youtube.com";@TLabAltoh
This wouldn't work. Instead, what I did, although I know it isn't the best option, is that I provided the URL inside the code snippet below.
m_NativePlugin.Call("initialize", webWidth, webHeight, tWidth, tHeight, sWidth, sHeight, **webViewURL**, dlOption, subDir, onPageFinish);
Perhaps the version of the submodule you are using is older than I have support for changing the initialise url at runtime.
In the latest commit, the Init function has an option to pass initialise url.
public void Init(
int webWidth, int webHeight,
int texWidth, int texHeight,
string url, DownloadOption dlOption, string subDir)
If you are updating the repository to the latest commit and submodule version, please consider using this feature.
Perhaps the version of the submodule you are using is older than I have support for changing the initialise url at runtime.
In the latest commit, the
Initfunction has an option to pass initialise url.public void Init( int webWidth, int webHeight, int texWidth, int texHeight, string url, DownloadOption dlOption, string subDir)If you are updating the repository to the latest commit and submodule version, please consider using this feature.
I am not sure whether I had updated both my repo and sum-module to the latest commit, but I tried the below:
git fetch origin master
git pull origin master
git submodule update --init
Please tell me the current commit ID of Assets/TLab/TLabWebView
commit ID
.... TLabWebView % git log -n 1
commit 9bd5542952a1b29a7c0520772cb0635c91441f75 (HEAD -> master, origin/master, origin/HEAD) Author: TLabAltoh [email protected] Date: Sat Mar 30 12:17:32 2024 +0900
revert webview url
Thank you, your module's commit ID is the most recent and properly updated.
Thank you, your module's commit ID is the most recent and properly updated.
and I do have the following inside my TLabWebView:
public void Init(
int webWidth, int webHeight,
int texWidth, int texHeight,
string url, DownloadOption dlOption, string subDir)
{
m_url = url;
m_dlOption = dlOption;
m_subDir = subDir;
Init(webWidth, webHeight, texWidth, texHeight);
}
Thank you, your module's commit ID is the most recent and properly updated.
and I do have the following inside my TLabWebView:
public void Init( int webWidth, int webHeight, int texWidth, int texHeight, string url, DownloadOption dlOption, string subDir) { m_url = url; m_dlOption = dlOption; m_subDir = subDir; Init(webWidth, webHeight, texWidth, texHeight); }
This is an overriding init function, this function can specify an initialisation url at runtime.