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
1
Question by c0d3n4m3 · Oct 15, 2014 at 12:47 PM · c#buildvariablesxml

Using an XML file to tweak variables after build?

I was wondering whether or not this was possible?

Would I be able to, once a game has been built, simply edit an XML file stored in the same game_data folder that would contain, say, Speeds of characters, jump heights etc and not have to rebuild the whole game just to change one variable?

(A better example) -> So upon loading of the *.exe file, the game reads my XML file and applies the variable tweaks in the game, to save me having to rebuild the game every time I change something as small as a characters move speed for example.

I remember friends used to do this with Flash games, and I was wondering if it's possible to do this with a Unity game.

As ever, I muchly appreciate any and all help/insight into my inquiry, and a massive thanks to you all!

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
0
Best Answer

Answer by Landern · Oct 15, 2014 at 12:52 PM

Of course you can, XML is just text. You can deserialize it into an object when you load a scene, hell you could create your own in game editor to serialize it back to xml if you wanted(in case you have beta testers or something).

An example from a previously answered question(http://answers.unity3d.com/questions/651714/learning-how-to-deserialize-xml-file.html). The links explain my favorite way of designing xml documents, which is to decorate the classes with attributes that describe the xml structure, after that, (de)serializing is quite simple.

         public static T DeserializeSettingsTemplate<T>(string path)
         {
             using(TextReader r = new StreamReader(path))
             {
                 XmlSerializer s = new XmlSerializer(typeof(T));
 
                 return (T)s.Deserialize(r);
             }
         }
 
         public static void SerializeSettingsTemplate(object dataToSerialize, string path)
         {
             using(TextWriter w = new StreamWriter(path))
             {
                 XmlSerializer s = new XmlSerializer(dataToSerialize.GetType());
 
                 s.Serialize(w, dataToSerialize);
             }
         }
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 c0d3n4m3 · Oct 15, 2014 at 04:22 PM 0
Share

Thank you so much for answering my question again! You rock! I'll always be forever grateful!

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

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Serialize Variables from Items in an Array 1 Answer

Flip over an object (smooth transition) 3 Answers

How to check if an int's value has decreased by 1? 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