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 Maccyjam · Apr 30, 2013 at 09:52 PM · javascriptwebplayerwww

Having Trouble with Javascript GET and URL

Through my Unity app and the HTML page it is embedded into, I am using the Facebook SDK to grab a user's details such as their user ID and name. Grabbing both and putting them into labels works fine. I have a template url that I can play an ID into to get their profile picture. However, when I try to use this url to get the image, it doesn't work when requesting the user's ID.

Here is the Unityscript code I am using:

 if (windowID == 1){
             Application.ExternalCall("GetCurrentUser");
     grabbedID = fbManage.fbUserID;
             if(!gotPic){
                   GrabPic();
             }
             GUI.Label(new Rect(200,100,500,500),getProfilePic.texture);
             GUI.Label(new Rect(200,600,500,500),aString);
     
     }
 
 }
 
 
 function GrabPic () {
     gotPic = true;
     aString = "ID is: " + grabbedID;
     var url = "http://graph.facebook.com/" + grabbedID + "/picture?type=large";
     getProfilePic = new WWW(url);
 }

Now what happens here is that the aString label displays just fine (when the profilepic is commented out), however when the var url and getProfilePic is not commented out, the game never loads the window with ID 1 and just crashes. What is unusual is that when grabbedID is defined manually, everything works as it should and the image is pulled as well as the aString label being displayed.

I am using a WebPlayer for this, and I have no doubt forgotten something so feel free to ask if more information is needed.

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

1 Reply

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

Answer by whydoidoit · Apr 30, 2013 at 10:44 PM

You aren't yielding the WWW getProfilePic and so not giving it any time to process - I'm guessing the hard coded value is just cached already or something. Presuming this is in a MonoBehaviour you should just be able to:

 if (windowID == 1){
            Application.ExternalCall("GetCurrentUser");
     grabbedID = fbManage.fbUserID;
             if(!gotPic){
              GrabPic();
             }
           if(retrievedPic)
           {
              GUI.Label(new Rect(200,100,500,500),getProfilePic.texture);
              GUI.Label(new Rect(200,600,500,500),aString);
           }
  
     }
  
 }

 var retrievedPic = false;
  
 function GrabPic () {
     gotPic = true;
     aString = "ID is: " + grabbedID;
     var url = "http://graph.facebook.com/" + grabbedID + "/picture?type=large";
     getProfilePic = new WWW(url);
     yield getProfilePic;
     retrievedPic = true;
 }
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 Maccyjam · May 01, 2013 at 02:55 PM 0
Share

Ah, works exactly as it should now. Can't believe it was something as simple as that! Thanks a lot! I assume it wasn't working because there was no 'getProfilePic' object to access then? Anyway, 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

13 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

Related Questions

Is WWW class usable in Android platform? 1 Answer

WWW Request runs in Editor but not in Webplayer 1 Answer

Is HttpWebRequest supposed to work in Web Builds or not? 1 Answer

How To Use LoadUnityWeb To Load a New Webplayer 2 Answers

WWW zero sized post buffer error Standalone 1 Answer


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