This article is an excerpt from Learning C by Developing Games with Unity 2017. In this tutorial, we help you to get started with creating arrays, lists, and dictionaries effectively. I've tried to list these in the order of how easy it is to add and remove strings from the file. A key ingredient in scripting 3D games with Unity is the ability to work with C to create arrays, lists, objects and dictionaries within the Unity platform. JSON files are generally industry standard for data storage these days, but eventually it is up to you which format you find easiest to work with. However, you can only use this format by writing your own parser, or using a third party one, because there is no built in parser. It is also the format that Unity uses for its serialisation. YAML is basically the same as JSON, but with less brackets. With JSON, if you architect it correctly, you can use Unity's built in JSON utility, or other better ones, to read the data directly into C# object classes.Ī decent video explaining this can be found here. You can then write some simple parsing code to read each line from the file, and split out the ID and the value and store it in a dictionary. You can export the sheet as a CSV file and load into Unity. Essentially, you would store an ID that you refer to the various strings with, which would be constant across language files.īasically, you can use some spreadsheet software (like Google Sheets) and have all your speech there a column for the ID of the string, and a column for the actual value. There are a few good ways to store this information, especially if you are localising them too. Ps:Don't mind all the variables being public, they are this way right now to make some parts of development easier, i will change the necessary ones when the time comes. My question is: what is a general good-practice way to store this type of data? I'm fairly new to unity and the only way i found to do this yet is through declaring a List on monobehaviour classes and editing them through the Inspector but this does not seems to be a effective way of handling this in a game that's going to have 1000+ different "Speech". This "Speech" class should never be changed during runtime and only needs to be read during dialogues. Public string Name // the name of the character that is speaking Public LocalizedString SpeechOrigin // Holds a reference to a localizedstring that is what that character is saying based on the language. Public Sprite CharacterHead // Holds a reference to a sprite which is the "head" of who's currently speaking I'm making a visual novel and my game uses some custom classes that store important data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |