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 Bru345 · Apr 25, 2014 at 04:12 PM · databasejsondatawwwformwww.loadimageintotexture

Calling Json script and displaying the Images within the script

I'm trying to access a Json script, it is in a domain. The script holds a couple of images, which are hyperlinked. I've tried using WWW to access the script, but the image i received was a picture of a huge red question mark. Clearly I'm going about the wrong way with this. So i'm assuming I'm supposed to decode the json script through unity and then display the image with the ability to see next/previous image by clicking? I'm unfamiliar with Json so how about would i call the script and read the the images it's calling?

This is what my code looks like, the code works since I've tried another non Json domain with just an image- and it works perfectly fine.

     void Start ()
 
     {   
         renderer.material.mainTexture = new Texture2D(4,4, TextureFormat.DXT1, false);
         url = "http://hosting.xivmedia.com/JsonHome/JSON/more_games.json";
        
             www = new WWW(url);
             StartCoroutine(WaitForSeconds(www));
     }
 
     IEnumerator WaitForSeconds(WWW www)
     {
         yield return www;
         www.LoadImageIntoTexture(renderer.material.mainTexture as Texture2D);
 
         if (www.error == null)
         {
             Debug.Log("WWW Ok!: " + www.data);
             imageLoaded = true;
 
         }
         else
         {
             Debug.Log("WWW Error: " + www.error);
         } 
     }
 
     void OnGUI()
     {
         GUI.DrawTexture(new Rect(20, 80, 100, 100),     renderer.material.mainTexture as Texture2D,  ScaleMode.StretchToFill);
  
     }


 

s

Comment
Add comment · Show 2
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 Graham-Dunnett ♦♦ · Apr 25, 2014 at 10:04 PM 1
Share

I assume the WWW call with the json URL will give you a text file that you're supposed to decode. Once you have the json file, look at it and see what it contains. I'd guess it'll have the URL to the images, and you'd then kick off other WWW calls to get each one.

avatar image Bru345 · Apr 26, 2014 at 02:57 PM 0
Share

I see, how would i go about decoding it? Also I need my script to be dynamic, since I might add more images to my json file when my game is live.

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

Dynamically load json data to a game: What are the best practices? 1 Answer

How to Pass a Json as Post Data to WWWForm 2 Answers

What is the best approach to filter large data sets in Unity? 1 Answer

WWWForms and sending data to database dont work 2 Answers

Data Management Issue - How to manage retrieved data from mysql? 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