To manage character information in unity

Asked 1 years ago, Updated 1 years ago, 92 views

I'm trying to make a game with Unity for the first time.

I am currently struggling with how to manage the character's information.

  • Character name (string type)
  • Catch copy (string type)
  • Introduction (string type)
  • Attack power (numerical)
  • HP (numerical)

I would like to assign this information to each character and manage it.
Hard coding makes it difficult to change and modify, so I want to manage it like a database and ask them (read and write), but I don't know how to do it.
In the first place, I can't decide whether this method is appropriate or not.

I'm planning to export the product for HTML5 (WebGL), so could you please let me know if there is a good way?

unity3d

2022-09-30 21:13

2 Answers

Please accept it as one solution.
Answer with the assumption that you will use Json.

Place a directory directly under Resources to store data and

{
    "id"—1,
    "name": "instant",
    "detail": "Young Agent of Celestal Being",
    "name2": "Gundam",
    "atk"—1000,
    "hp"—1000
}

It creates a data structure like this.
You can retrieve data using Resources.Load.
It's the same when using a server, and the server side converted the data to Json.<> I think you can design it accordingly.
You will need an ID in the future, so I think it would be better to set it up.

Also, if you parse this Json data and make it into a class or associative array,
I think I can design it flexibly.

If you want to be able to see it in the inspector, you can develop your own Editor and
Prepare your own GUI.
*It should not be so difficult if it is implemented along with data reference.

I hope this is the answer I was looking for.


2022-09-30 21:13

I've never touched Unity, so I don't know if it's possible, but I think it's better to manage simple metadata in a file.Of course, DB is fine.
The data structure of the file is JSON, XML, Yaml, toml, CSV.If you have any ideas, you may want to think about how to save the data yourself.


2022-09-30 21:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.