In C#, I can use
WWW.GetURL("http://unity3d.com/Documentation/ScriptReference/WWW.html");
to block execution while retrieving a web page. However, I can’t use
WWW("http://unity3d.com/Documentation/ScriptReference/WWW.html");
to get the web page asynchronously (non-blocking). What is the correct syntax for C#? All the examples in the manual and wiki are in JavaScript.
Thanks.
To create an object in C# you must add the new keyword to the statement, which is optional in Javascript:
new WWW("http://unity3d.com/Documentation/ScriptReference/WWW.html");
Thanks for your reply, freyr. When I try “new WWW…,” I get the following error message:
“the type ‘UnityEngine.WWW’ has no constructors defined”
So, if WWW is an object, why does it have no constructors, even default? And, if I should use a coroutine here, which function is the coroutine, assuming it is supposed to return an IEnumerator type? (GetURL returns a string)
I am still pretty new to C# (though I have extensive C++ experience), so I may be misunderstanding the language somewhere. I’d like to solve this problem, and see a working example in C#.
Thanks for any clarifications!
You will have to use JavaScript for this one. There is an issue in the bindings which makes the constructor unaccessable from C#. C# bindings will work with Unity 1.6.
Not a problem. Thanks for the info!