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 Dudledok · Aug 13, 2014 at 11:43 AM · c#textloadxmllevel

Creating 3D levels with text and XML files

I am making a 3D platforming game.

I am currently creating levels in the Unity editor, but also allowing users to select text files from a folder and load them in. The text files are read to create 2.5D levels with all platforms / objects at the same height. I could vary the heights of objects by increasing the size of the key for the text file (as in p for platform, hp for higher platform etc) but this is messy and complicated.

I was thinking of how I could go about associating objects in the scene that have been loaded from the text file with data stored in an xml file to somehow describe how to position objects.

Has anyone done something like this has suggestions? Or perhaps there is a better alternative route to take? Thanks in advance for any assistance you provide. If you wish to know more about what I'm doing, just ask.

Edit: @daybson.paisante this is less a question of the literal process of loading xml, but rather how I would go about linking the retrieved value to the objects in the scene to create a 3D world. Hopefully that makes it clearer as to what I would like to achieve.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Kaz_Yamof · Aug 13, 2014 at 12:29 PM

Maybe helps: http://wiki.unity3d.com/index.php/Save_and_Load_from_XML

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

Answer by Bunny83 · Aug 13, 2014 at 01:24 PM

There are multiple ways of how to map "string based data" to GameObjects / prefabs.

  1. Just create an array which holds all available prefabs. In your XML data you can simply use an index number to select which part you want to use.

  2. Create an Dictionary based on the array approach of point 1 so each part can have a human readable name. The dictionary will help you mapping a part-name-string to an actual prefab

  3. Use the resources folder to manage your prefabs. You can simply use the string you got from your XML data and use it with Resources.Load to get the desired prefab

The XML data can hold additional information such as an offset, orientation, color, ... or even more complex information such as links between a door and a lever. However that depends on what your level is made of.

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 Dudledok · Aug 14, 2014 at 08:02 AM 0
Share

The latter is essentially what I want to do. I want to link buttons with platforms. I have buttons in my scenes which change the colour of platforms when pressed. I can easily link a button to all platforms, but now I want to link them to specific platforms.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

SaveLoad Profile c# to xml 4 Answers

Save and Load data from Local XML file won't work 1 Answer

Need help with XML Parsing. (C sharp) 1 Answer

Null Reference Exception while trying to access Text Files 1 Answer

How to update text every time I press space? 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