Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question Making scriptable objects moddable

Discussion in 'Scripting' started by maxieboyyy, Nov 7, 2022.

  1. maxieboyyy

    maxieboyyy

    Joined:
    Jun 8, 2018
    Posts:
    2
    Hi all,

    I'm a rookie programmer who is working on his first larger project after a few of small ones.

    I'm making a management game kind of like football manager but on a smaller scale. I want the game to be moddable in a way that people can add players to the player database as I have no license for real players and thought it would be a good way to get a small community on the game.

    I'm using Scriptable Objects right now for my player data. I decided upon this as I saw a few people suggest this as a sort of database management for unity games.

    My question is as followed: Let's say I have a list of 10 players. My game will show this list and once clicked upon each player will have their details shown. Right now each player in that list is a scriptable object connected to a database item. I want to change this to where each ScriptableObject in the folder is shown. So let's say someone adds 10 (after the game is build) to that folder, they will show up in that list and now a total of 20 players will be availlable.

    Is what I want possible at all? Is there a different way to do this in case this isn't the best way or do I need to switch engine as this type of game is not fit for Unity.

    Thank you so much for reading, I hope I didn't break any forum rules (as this is my first post) and I hope I don't sound to dumb with my question.

    Thanks again!
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,003
    When the game is built, all assets are built into various bundles, save anything in a StreamingAssets folder, and are not mutable beyond that point.

    In your case, you would probably better off representing your player's raw data as something like a JSON object. These can easily be written up in a text editor like Notepad++ and imported at runtime. You'd just need a C# class that matches this JSON, and you could even wrap these in your scriptable objects so as to be able to design them comfortably in the editor.

    So your homework I guess is learning how to serialise and deserialise a C# object into JSON, and develop a means to load these in a built runtime project (most likely from Application.persistantDataPath).
     
  3. maxieboyyy

    maxieboyyy

    Joined:
    Jun 8, 2018
    Posts:
    2
    thank you so much! that makes a lot of sense actually. Gonna look into that right now :)