- Home /
 
Unity Web Player WWW Call
Hi,
I read all the forums and threads but still no idea how to do it. So here is my question.
I am making a game now and it's done on mobile but i have some problems with facebook web player build.
My game has in-app billing where you can purchase coins.
On facebook i need to use facebook payment system. Everthing works ok and returns te expected values. On mobile when the user purchases 10 coins in the callback function i set the 10 coins in PlayerPrefs. And i can retrieve / modify whenever i want.
When i do this (PlayerPref) on the facebook game i can not user the PlayerPref because this info is set on the users pc and if he tries to play from elsewhere the coins will be lost.
So i made a class that call a php script on my server and WAITS for the returned value from PHP.
Also this works as expected on Unity Player in Editor. But when i try it on facebook it crashes due to www.isDone loop that hold it.
This is how i do it:
From facebook callback function i do :
 CoinsFacebook c = new CoinsFacebook();    
 int currentNumberOfCoins = c.updateNumberOfCoins(10);
 
               In the CoinsFacebook.cs i have the method updateNumberOfCoins(int number);
 public void updateNumberOfCoins()
 { 
      
       string url = "url";
       WWW www = new WWW(url);
   while (www.isDone == false) 
   {
         //do nothing    
   }
   numberOfCoins = int.Parse (www.text);
       return numberOfCoins;
 }
 
               But this is not working. Also i have a function getNumberOfCoins() which does the same thing (it retrieves the number of coins from server)
How can i make the script to wait for the result and then return the value? I tried with coroutines but apparently i can not do that because i do new CoinsFacebook()...
Please help me
Your answer
 
             Follow this Question
Related Questions
Scene is being loaded with delay in facebook game which is made in unity 0 Answers
how to post message on friend wall in facebook? for ios 1 Answer
Custom Event System, Coroutines, Callbacks? 1 Answer
How to integrate facebook to unity project for android and ios 1 Answer
how to post message on friend wall in facebook? for ios 0 Answers