Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 manuelmangual · Apr 30, 2016 at 11:39 AM · c#unity 5json

Issues with JSONUtility

I have this JSON file:

 {
   "Name": "Corellian Engineering Corporation",
   "Title": "CEC",
   "Version":  "1.0",
   "DateCreated": "2016-04-29T14:00:00.00",
   "CreatedBy": "Manuel Mangual",
   "Path": null,
   "LastUpdated": "2016-04-29T16:00:00.00",
   "LastUpdatedBy": "Manuel Mangual",
   "Settings": [ ],
   "Objectives": [ ],
   "Scenes": [
     {
       "Name": "YT1300",
       "Title": "YT1300",
       "SourceImage": "Assets/Graphics/UI/milleniumFalcon.jpg",
       "Description": "YT-1300 light freighters were a type of light freighter that operated in the galaxy during the final days of the Galactic Republic and the reign of the Galactic Empire. Its side-mounted cockpit and front-facing prongs allowed it to push containers in orbital freight yards. The Millennium Falcon, originally known as YT-1300 492727ZED, was a modified YT-1300 light freighter with a storied history stretching back to the decades before the Clone Wars and the rise of the Galactic Empire. Manufactured by the Corellian Engineering Corporation in 60 BBY, the light freighter was first owned by Corell Industries Limited and underwent several name changes before being bought by the smugglers Kal and Dova Brigger in 48 BBY, and the ship eventually ended up as the property of the secretive Republic Group under the name Stellar Envoy by 29 BBY. The Envoy was destroyed in a collision with a bulk freighter above Nar Shaddaa, but it was rebuilt and served various owners under different names before Quip Fargil named it after the bat-falcon, and it eventually fell into the hands of Lando Calrissian after a game of sabacc—but Calrissian himself lost the ship in another game of sabacc to the smuggler Han Solo several years later.",
       "Areas": [
         {
           "Name": "Cockpit",
           "Title": "Cockpit"
         },
         {
           "Name": "EngineRoom",
           "Title": "Engine Room"
         },
         {
           "Name": "NumberThreeHold",
           "Title": "Number Three Hold"
         },
         {
           "Name": "Hyperdrive",
           "Title": "Hyperdrive"
         },
         {
           "Name": "Hyperdrive",
           "Title": "Hyperdrive"
         },
         {
           "Name": "MainHold",
           "Title": "Main Hold"
         },
         {
           "Name": "PassageTubeToCockpit",
           "Title": "Passage Tube To Cockpit"
         }
       ]
     }
   ]
 }



and what I want is to load its elements into Unity GUI objects I set up in the inspector. I made this class for that purpose:

 using UnityEngine;
 using System;
 using UnityEngine.UI;
 
 public class ShipDataReader: MonoBehaviour {
 
     void Start()
     {
         Scenes _scenes = new Scenes();
 
         string json = JsonUtility.ToJson(_scenes);
 
         _scenes = JsonUtility.FromJson<Scenes>(json);
         
     }
 }
 
 [Serializable]
 public struct Scenes
 {
     public int index;
     public string title;
     public string description;
     public Image sourceImage;
     public string[] shipSection;
 }


but the problem is that it doesn't read the json file I created. Can anyone help me structure this class so it can read from the correct json file? And also, how would I be able to access each element in the json file? Thanks in advance!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity json get data 2 Answers

How can i get all of my users data on FireBase and store it as an array using Unity and RestClient json 1 Answer

Null Reference exception when loading json data to dictionary 1 Answer

Can't read float array into C# from JSON using Simple JSON 2 Answers

Multiple Cars not working 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