TLabWebViewVR icon indicating copy to clipboard operation
TLabWebViewVR copied to clipboard

set the webview URL dynamically

Open HafizMSaad opened this issue 1 year ago • 10 comments

Is there any method other than using the inspector where I can dynamically set the URL based on certain conditions?

HafizMSaad avatar Mar 29 '24 20:03 HafizMSaad

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.

TLabAltoh avatar Mar 30 '24 03:03 TLabAltoh

What if I provide a URL in the following code? [SerializeField] private string m_url = "https://youtube.com"; @TLabAltoh

HafizMSaad avatar Apr 01 '24 05:04 HafizMSaad

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);

HafizMSaad avatar Apr 01 '24 06:04 HafizMSaad

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.

TLabAltoh avatar Apr 01 '24 16:04 TLabAltoh

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.

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

HafizMSaad avatar Apr 02 '24 04:04 HafizMSaad

Please tell me the current commit ID of Assets/TLab/TLabWebView

TLabAltoh avatar Apr 02 '24 04:04 TLabAltoh

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

HafizMSaad avatar Apr 02 '24 04:04 HafizMSaad

Thank you, your module's commit ID is the most recent and properly updated.

TLabAltoh avatar Apr 02 '24 04:04 TLabAltoh

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);
		}

HafizMSaad avatar Apr 02 '24 04:04 HafizMSaad

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.

TLabAltoh avatar Apr 02 '24 08:04 TLabAltoh