Home > OS >  Save log to a string
Save log to a string

Time:09-09

I am debugging a webpage inside Unity that gets printed to a console. How do I copy the debug message into a string?

public string message; //print to this string

void SomeFunction(){
web.ExecuteJavaScript ("document.querySelector('iframe')).click();", s => Debug.Log (s));
}

CodePudding user response:

You just need to assign s to the target string:

public string message; //print to this string

void SomeFunction() {
   web.ExecuteJavaScript ("document.querySelector('iframe')).click();", s => {
      message = s;
      Debug.Log (s);
   });
}

CodePudding user response:

This should do the trick

public string message; //print to this string

void SomeFunction(){
    web.ExecuteJavaScript ("document.querySelector('iframe')).click();", 
    s => {
       Debug.Log (s);
       message = s; 
    });
}
  • Related