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
0
Question by rzv.avram · Apr 08, 2014 at 03:33 PM · facebookcoroutinescallbackin-app

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

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

21 People are following this question.

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

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


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