x


How can I read a php file in localhost or remote from unity editor

Hi

I red this on lots of links, but I cant make it work for me.
What I want to do is to use this peace of code and use it to read a file on my localhost.
I use PHP in localhost. Id like to make some sort of communication with unity, but that is not important at this point. Id just like to make my 2 apps talks somehow from editor.

   var w = WWW(url);   yield w;
    if (w.error != null) { 
      print(w.error); 
   } else { 
      print("Test ok"); 
      formText = w.text; 
      print(formText);
   } 

I have managed to make a call only like this: I build a project, move it to my localhost (http://localhost/unity/test/WebPlayer.html), and from there make a call, and it works remotely, my online(or offline) files are updated when I make a call, but I can`t make it work from within unity3d editor.
Can that be done at all?

Thanks in advance,
this is my first post, so I might have posted it wrong, on wrong place, etc.

EDIT: When I set a default build as "standalone", I can communicate with server through unity editor.

more ▼

asked Aug 06 '11 at 01:05 PM

Mefistofelos gravatar image

Mefistofelos
1 1 1 3

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Have you configured the WWW Security Emulation settings in the Editor?

My understanding is that the Editor will attempt to emulate the security restrictions imposed on the web player.

If you go here:

 Edit -> Project Settings -> Editor

You can then specifiy the URL where your game will be hosted in the Inspector.

This will allow the Editor to simulate the security restrictions that will be imposed on your game if you publish it to that address.

This does not explain why you wouldn't be able to access a php script running on the same host as a published game.

http://unity3d.com/support/documentation/Manual/Security%20Sandbox.html

more ▼

answered Sep 14 '11 at 02:32 AM

jahroy gravatar image

jahroy
3.2k 14 18 42

(comments are locked)
10|3000 characters needed characters left

It's possible that the Unity Editor is being blocked by your computer's firewall. Check the firewall configuration to make sure there's an exception for it.

more ▼

answered Aug 06 '11 at 05:46 PM

sneftel gravatar image

sneftel
1.7k 7 9 20

I found out later on today that when I set a default build (in unity options) to stand alone or windows build, it works, sends data to my online/offline server. It dont work when default build is set to webPlayer tho. Should it work?

Aug 06 '11 at 06:20 PM Mefistofelos

any suggestions on this yet? Even my uploaded webplayer wont connect to the php in same directory. I might just be doing it wrong.. I tried url= http://address.com/scores.php, http://localhost/scores.php, just /scores.php, nothing. worked in stand alone for me too. always asks for the crossdomain.xml which doesnt work.

Sep 14 '11 at 12:49 AM Wulfeous
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1730
x136
x27
x8
x8

asked: Aug 06 '11 at 01:05 PM

Seen: 1304 times

Last Updated: Sep 16 '11 at 06:06 AM