Unity - "How to center and update all Game variables?"

Asked

Viewed 238 times

0

Engine: Unity (5.4.3).

Scripting language used: C#

Setting: The game is divided into scenes, each scene composed of enemies and traps, each enemy composed of their weapons, and each of these elements composed of their respective variables.

Problem: Now, in the game swing stage, not to become a handmade work, modifying the parameters of each enemy and trap separately (or even through their respective prefabs)... I wish to do something like: "Centralize all variables in a database that I can easily update in batches"

Considerations:

  • It needs to be in table format (csv,fdb,xlsx,sql);
  • It needs to be "offline", like an Embedded mini-database;
  • Could be "Assets" from Unity Asset Store who have had experiences of satisfactory use;

1 answer

1

If you’re using C#, here’s an idea: Create a class in the Singleton standard and use properties in that class. This way you can use them at any point in the game. (It can be a static class too, but I would use a Singleton myself). You can make the "set" of the properties already update the value in the bank and the "get" already return from the bank as well, which would speed up a lot, but I do not know if this can be good in your case for performance reasons, but it is worth the test.

  • This is a good way. However, concurrent access to a single Singleton object can be complicated if information is updated during the game (if only read, ok). Another alternative is to store the data in a local structure and make each object know how to read/update its own data. There will be shares, but only instances at the same hierarchical level.

  • 1

    As for the implementation, if it needs to be in "table format" (type CSV - but why?), you will have to implement Ivan. But Unity has solutions to this with the PlayerPrefs and even with XML serialization.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.