Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Reading from config.ini etc. files?

Discussion in 'Scripting' started by Ravel, Apr 20, 2012.

  1. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Hello, I was wondering if there are any good, fast and simple ready to use scripts for reading configuration files?

    For example:
    Code (csharp):
    1.  
    2. car
    3. {
    4.   make=Nissan
    5.   model=200SX, Silvia S15
    6.   production=19992002
    7.   box
    8.   {
    9.     length=4.445
    10.     width=1.694
    11.     height=1.285
    12.   }
    13. }
    14.  
    and could be read by a function such as:

    Code (csharp):
    1.  
    2. openconfig("data\cars\sx200\car.ini")
    3. carname=readinput("car","model")
    4. carlenght=readinput("car\box","length")
    5. closeconfig()
    6.  
    I know its a really simple task actually, but i was wonering if there is something like this out there allready or do i have to reinvent the wheel?

    Thanks for your time help!
     
  2. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    Why not XML?
     
  3. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    I'm not familliar with xml benefits, for me it seems xml has a little to much info in them and at some point confusing to edit imo.
     
  4. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    It sounds like you don't know about XML, but you made up your mind already.

    Your way is fine, too, but you can't yet implement it anyway.
     
    Last edited: Apr 20, 2012
  5. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Hmm so you are saying that XML is the only way to get input at this time? Well if this is the only way I'm willing to start using it, I was just thinking that this has been done befor (reading data from whatever files). Thanks for your replys anyway!
     
  6. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    No, it's not the only way to read a file, but it makes life quite easy.
     
  7. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Could you tell/show me your view of xml and how does it make life easyer? For me i have seen that xml has alot of comands im them and by the looks of it seems more time consuming creating xml?
     
  8. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    Are you unwilling to do your own research?
     
  9. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    So you are another one of those oldschool "I know everything" trol who teaches others to use google.com, rather than actually giving advice and helping? I dont want to be rude, but whats the point of your posts if you are not here to help, boredome?
    Yes i can do my own research, but i do have other things to do rather than wasting time searching on something simple this is why I asked the forum for help (this is why forums actually are invented for community, helping, sharing, showcasing etc.).
    Thake it this way, if it wasnt for people like me people who actually help, there wouldnt be anything to google for.
    I'm sorry if I pissed you of right now but I honestly didnt wait for "search it yourself" attitude.
     
  10. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    I'm pretty sure you're lying when you say "I don't want to be rude".

    You have other things to do with your time, but I don't have anything better to do than teach you how to use XML or StreamReader? If it's simple, why do you need help?
     
  11. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Actually no Im not lying, Im not here to fight. And I have allready said why I posted here. Since it seems you are enjoying 4/20. I'm telling you what im doing. Im currently working on my project(cleaning the code, fixing some bugs, finding solutions for my ideas) and meanwhile checking, if there is some advice posted in here. If there was a reasonable post here I could continue one part of my project. And it's simple because it's a simple task to do for a computer and by that I am sure the code cant be that much of a deal. I mean it's not a complex task as writing your own shadow system, to cast and receive shadows from multiple light sources.
     
  12. Poupi

    Poupi

    Joined:
    Jan 11, 2012
    Posts:
    111
  13. rqpaine

    rqpaine

    Joined:
    Oct 6, 2011
    Posts:
    69
    so I have a question. I really hate XML, I just dont like it at all. What other options do I have?
    I recently discovered JSON but havent had time to look into it. Is it a good option in unity?
    Other than writing a plain text parser, what else could be done?
     
  14. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Thanks for the useful links Poupi!
    rqpaine, why do you wxactl yhate XML? I personally dont like XML because it has too much unnececary info in it, id prefeer a plain text parser, since I would really like to change information with a simple touch to the configuration files from a notepad etc. another reason why i like text, is that im planning to make my project user friendly, so that user made contet would also be an option.
    So yeah if there are some other options im also interested.