Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is it possible to make my game moddable?

Discussion in 'Editor & General Support' started by WarpZone, Feb 16, 2008.

  1. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    Hey. I know Unity is very good about storing all the assets internally, but is there any way I can force it to store the art assets externally? Maybe even use some type of XML or TXT file to dictate what should be loaded when and some simple gameplay variables? The goal is to make it easy for players who don't have Unity to mod my game.

    I'm leafing through the documentation, and so far it looks like you can't even tell Unity to read and parse external txt files... hopefully I'm wrong about this, or maybe someone's made a plugin?

    Thanks in advance.

    Info found so far:

    Can I read and write text files using Javascript?
    How to write a file?
    NET Framework Developer's Guide: Writing Text to a File
    Mono Documentation
    MSDN .NET documentation
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There's quite a few topics about reading external text files if you look around. In short, you use .NET for that. You can also use the WWW class to read external .jpg and .png files easily (just use "file://" instead of "http://"). You can read arbitrary binary files (using ReadAllBytes or some other method), but you have to parse them yourself. Also look on the wiki for a script to do mesh serializing.

    That's for the stand-alone and doesn't work with web players as far as I know.

    --Eric
     
  3. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    Thanks for the info! :)

    Does this mean I need to use .NET as my scripting language? Most of the tutorials I've seen so far have used JavaScript. Or can I just mix and match the different scripts depending on what utility I need?
     
  4. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    As the Unity Javascript is based on .NET, you have full access to the .Net API from Javascript as well as from C# or Boo.
     
  5. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    Oh okay.

    I haven't worked with the .NET API before. I'm not even sure what an API is. Is it documented on this site or would I need to go to some .NET site to get a list of all the commands and what they do?
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Application Programming Interface. You can use the Microsoft .NET reference or the Mono documentation, which is less annoying but also incomplete. This is one of a number of text read/writing topics which should get you started.

    --Eric
     
  7. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    I notice it uses an import command with no other explaination. Do I need to download some kinda library and set it up first? Or is that included with Unity?
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's just a way of shortening things. So instead of typing

    Code (csharp):
    1. sr.System.IO.WriteLine
    all the time, you import System.IO so all you have to do is type

    Code (csharp):
    1. sr.WriteLine
    --Eric
     
  9. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    Ah, okay. I've done this before in Flash when working with objects defined in certian packages. You import the library (in this case System.IO) and then the objects and methods in that library become exposed and ready to use in the current block of code.

    I guess I'll have to start digging through all that documentation. I need to get a grasp of the commands at my disposal before I can even begin planning what I'm about to do.

    Thanks again, guys. :)
     
  10. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    Um, okay... in the .NET Framework Class Library documentation, I've found the entry for the System.IO Namespace, but I don't see any System.IO.WriteLine method listed here.

    Is this the wrong version of the documentation? Am I just reading it wrong? What gives?

    Edit: Okay, I get it now. Clicking on the class name won't give you a detailed description of the class like in the Flash documentation. Instead it just gives you a brief summary and some crappy technical details. In order to get method names and such, you need to click on the left and expand the class's entry on the tree. That's... both more consise and more obtuse. I'm literally 50/50 on whether or not this is a better way of organizing the information.