String Storage Methods

9005680--1241107--Strings.gif

When I was 16 in 2006 I modded some computer games, and saw that they use to often store their strings in a huge DLL. Like for full sentences of string for example. For raw development, we all know that writing a string Add(“String”); is a garbage producing machine. And so sometimes its nice to specify Add(OUR_STRING) to memory, but to assemble those private strings we have to draw that data from somewhere.

and that is where the conjecture lay.

Do you know why a .dll would be used over a standard text file to store strings? Is there some kind of reading advantage in that?

It’s called a Resource library. It’s generally an autogenerated DLL file from a resources table (in .NET world a .resx file which is just an XML file). Very useful for localization (translation) of strings.

2 Likes

What do you use? Do you make an xml?

Unfortunately resx files are not supported by Unity directly, they preferred to have their own localization system/library, but you can always recreate this functionality using your own Unity Editor scripts/tool that can read the resx files (it’s just an XML file after all) and autogenerates all localization strings in a TextResources class, just like what VS does in other .NET projects:

This file is automatically generated from the resx files I have in my project. Now all I have to do to get a string is to call TextResources.Front_Camera and it returns the correct string for the current selected language (culture).

Now I can use the standard VS resx editor tools to add/edit localizations:

Or even better, use the excellent free VS plugin ResXManager that makes it super easy to add/edit resource, translate it automatically using several online translation services, detect problems in punctuations…etc

And finally I can send the main resx file to translation companies since it’s a standard format supported by most translation companies.

1 Like

Wow that’s pretty amazing stuff ! Thank you for sharing. Very smart because it can take a long time to do these things manually by script. I have never seen anything like this before looks like some serious stuff! I love how easy it seems to put an Arabic translation alongside. Hm

Smart indeed. Scalable since if I had a full storied game, hell and I had a bunch of languages and I was pulling strings from text file based on which line they were, the mess that could cause if I had a Chinese file a English file a French file. But to have a nice view where the string is formally input and then some variations display alongside that’s very nice.

1 Like

Don’t worry about all of this, Unity’s own library is pretty solid too and have nearly the same functionalities.

Check their Quick Start guide.

I just preferred to use Resx files and basically re-implement what Microsoft did for .NET into Unity since I’m a long time .NET developer used to work with Resx files intensively and the tools around it, and also needed to have more freedom in the resource retrieval system to implement some advanced things since I’m not using Unity standard UI system, but Noesis GUI (which is a XAML/MVVM UI system for Unity just like WPF, the framework I’m used to work with for more than 15 years) to be more productive.

1 Like

I might do the multi file approach and use regular numbers to identify lines and dock the characters out.

I can’t believe I have never done these unity early learning tutorials lol I never knew they offered this, I think I’m comfortable with a text file so il work with that.

1 Like

Do whatever you find easy/better, the most important thing is that it works.

2 Likes