Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by buxton4life · May 02, 2012 at 12:02 AM · webplayerwwwphpscores

php WWW not working in unity web player

Hi guys,

Got a problem with php in my game, it works in standalone player and mac osX version etc but does not work in the web player when built.

The game was built in to the same file as the crossdomain.xml and web server so I don't think that's the problem. And I am not using loops, I think I am using yield correctly. Any help would be much appreciated!

  var highscoreUrl="http://localhost:8888/********/resources/get_score.php?";
  public var stylish = new GUIStyle();
  public var stylish2 = new GUIStyle();
  public var stylish3 = new GUIStyle();
  public var stylish4 = new GUIStyle();

 function Start(){
   var hs_get = new WWW(highscoreUrl);
 yield hs_get;
 if(hs_get.error) {
     print("There was an error getting the high score: " + hs_get.error);
 } else {
    gameObject.guiText.text = hs_get.text;  //this is a GUIText that will display the scores in game.
    //formText = hs_get.text;
   }
 }

 function OnGUI(){
 if (GUI.Button(Rect(-70,0,250,40), "Main Menu" ,stylish2)){
         Application.LoadLevel("MainMenu");
     }

 GUILayout.BeginArea (Rect(100, 70 ,Screen.width -200,80));
         if (GUI.Button(Rect(0,0,200,40), "" ,stylish3)){    
             Application.LoadLevel("LeaderBoards");
         }    
         if (GUI.Button(Rect(210,0,200,40), "" ,stylish4)){
         }
         if (GUI.Button(Rect(420,0,200,40), "" ,stylish)){    
         }
     
 GUILayout.EndArea();
   }
Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image rutter · May 02, 2012 at 02:34 AM 0
Share

What isn't working? Are you seeing any warnings or errors in the console/debug log?

avatar image buxton4life · May 02, 2012 at 02:40 AM 0
Share

Thanks for the reply rutter,

The results from this query should appear in a GUI text, it works in unity3d player with no errors in console. But when I built this to my local server the results do not appear at all.

It seems like there is no interaction with the server? Sorry to be vague.

avatar image Paulius-Liekis · May 02, 2012 at 08:35 AM 0
Share

Try checking your error log file after running in browser. That could help you understand what is happening.

avatar image buxton4life · May 02, 2012 at 01:18 PM 0
Share

Cheers for the reply guys, I wasn't aware of the console.app!

I found this error -

There was an error getting the high score: Rejected because no crossdomain.xml policy file was found UnityEngine.Debug:Internal_Log(Int32, String, Object) UnityEngine.Debug:Log(Object) UnityEngine.$$anonymous$$onoBehaviour:print(Object) $:$$anonymous$$oveNext()

Where exactly should I put the crossdomain.xml file?

avatar image Paulius-Liekis · May 02, 2012 at 02:19 PM 0
Share

Please post your answer as answer and mark it as correct, so other can see that it is solved. Welcome to Unity Answers!

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by buxton4life · May 02, 2012 at 10:37 PM

SOLVED!

The cross domain policy needs to be utf encoded <?xml version="1.0" encoding="UTF-8"?> also the file should be in the root or index of the web folder! Pretty basic mistake....thanks to Paulius Liekis and rutter for your input. :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sidvbhave · Jul 26, 2013 at 07:46 PM 0
Share

hey, I followed all the steps and I am getting absolutely no errors. though it works as an EX$$anonymous$$ The individual script that posts the data works well with .exe standalone as well as the we player builds. However if I run the game as web player, it does not work but surprisingly it works for .exe standalone build! I am having a hard time debugging this because there is no error printed as it was before, so ideally it should be working fine. But the data is not being written by the web player version of the game! Any suggestions of what I might be doing wrong? Thanks.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I properly send binary data (byte[]) to a MySQL database? 4 Answers

WWW Request runs in Editor but not in Webplayer 1 Answer

Yield return request never returns 0 Answers

Retrieving data from a WWW php call? 1 Answer

Any caching options available for things dynamically loaded by WebPlayer? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges