Excute JavaScript
Create your Unity Script
public class TestScript : MonoBehaviour
{
public EdgeCanvas m_edgeCanvas;
void ExcuteScript()
{
m_edgeCanvas.ExecuteScript("navigator.userAgent", (error, result) =>
{
if (error)
{
Debug.LogError("Excute Failed.");
}
else
{
Debug.Log(result);
}
});
}
void OnGUI()
{
if (GUILayout.Button("Excute"))
{
ExcuteScript();
}
}
}
Click the Excute button, and Unity will receive the following message
More usage methods
tip
console.log('hello')
Echo Log
tip
document.body.clientWidth
Get Body ClientWidth
tip
OnCustomFunction
Return the result of a custom method