Hello
I have some trouble using webrequest with the webplayer and from what I read on several post on the forum it’s simply incompatible with it… it is true ?
(Second bad news after I discover unity doesn’t support blendshapes, pleaze add it as soon as possible)
And second question, How can I go around this problem without using WWW class ? I can’t use WWW class because I absolutly need to use a C# “DLL” who use itself the webRequest class …
I really hope there is a solution ! Any Idea
Thank a lot
Jérôme Foucher
Question is: can you use additional DLLs on the webplayer at all?
I would have assumed the answer is no, as you otherwise could bypass cut features like harddisk access or what know I.
I thought you could only use whats present and is installed by the webplayer already, the unity files you upload don’t contain any runtime libs anymore, only your script code compiled + assets …
at least I was under that impression so far.
own DLLs are for standalone builds.
Yes we can use .Net “DLL”… Because it’s not true DLL as C++ Dlls. Just collection of .Net code, not native code dll.
So yes it’s possible and it s working very well.
It’s just fail in my case when this “DLL” try to call : WebRequest.Create(“http://”)
Jerome
Hum no answer, it’s really not possible at all to call C# WebRequest on webPlayer release ?
In fact I doubt it’s possible so I begin to transform the parts of code of the C# lib I need with WWW class instaed of WebRequest call … but it’s a bit hard to make it working !
Firstly because I’am not in a monobehavior class and that I can’t use coroutine. So I try to do this instaed :
public void SendRequest()
{
WWW www = new WWW(request);
while (!www.isDone)
ResponseText = www.data;
}
Again It works in standalone but not in webbrowser…
I know that I shoud use yield statement but I can’t because I can’t use StartCoroutine (because my class doesn’t herit from monobehaviour).
So how to do this ?
Hmm, I can successfully request WWW.data in webplayers AND standalones.
I do so using JavaScript though. Maybe try JavaScript first, and then discover why it wouldn’t work for you in C#?
EDIT: Sorry, looks like I missed the difference between the built-in WWW and webrequest.
Request data with WWW class is very simple with unity and work very well in most cases for standalone and webbrowser.
But what I try to do is a bit different :
I try to integrate a C# DLL absolutly not made for Unity. But it’s almost work … the only problem is that this dll use the webrequest class that doesn’t work in web player release.
So I try to convert all WebRequest call in this library (which is open source) with the WWW unity class.
Again it almost work and now the probleme is that i cannot retrieve the data with WWW without being in a monobehavior herited class …
And that only because I can’t do : while(!www.isDone){} in a webplayer release …
So my last question is how to get data with WWW class without using yield and coroutines ?
Thank you
You can use isDone in the web player. However since the download notifications from the browser are happening in sync you can’t write a simple while (isDone) loop. But you can keep on checking it from an Update loop somewhere.
Thank you for your response Joachim, if I understand correctly I must go out from the Update function where I am doing my request to let the download happen ? Do I need to leave it just one frame, or more ?
Thank you again
Jérôme Foucher
As Joachim indicated you need to move your isDone check to an Update event, checking isDone each update and when done, do whatever is necessary. Here is some quick untested forum code as an example:
private var myWWW : WWW;
function IssueRequest (aURL) {
myWWW = WWW(aURL);
}
function Update () {
if (myWWW != null) {
if (myWWW.isDone) {
// error check, pull data, etc.
myWWW = null;
}
}
}
Doing the above will let the WWW instance update the isDone status and you check it using Update events instead of using yield/coroutines.