I started using Localization Package and it works very well when I’m building from Editor. The Streaming Assets folder is created in the build folder. But when I’m building the app from github and there I’m using batchmode so no editor it doesn’t create a Streaming Assets folder. I found similar issue here Issue with StreamingAssets copy when running Unity in batchmode - Unity - FMOD Forums and they are saying that scripts are not run when running in batch mode. Is it possible that this is similar issue? Do I need to manually execute some script when running in batch mode?
I tried to put it in OnPostprocessBuild or OnPreprocessBuild and in both I’m getting “Cannot build asset bundles while a build is in progress.” Is there example of where should I put this?
You would need to create a new static method that calls AddressableAssetSettings.BuildPlayerContent() and then calls BuildPipeline.BuildPlayer(). This new method can then be invoked in batch mode.
Worked like a charm. Was this somewhere in the docs of Unity Localization Package? If not maybe it would be helpful to put there somewhere as a gotcha type of thing or FAQ.
one more thing even though its not related to the previous problem. If I’m creating lets say
StringDatabase or StringTable, this table is key - value pair. Then I will use the key lets say somewhere in the code to get the localized value. Now I’m thinking what’s the best practice on using these keys. If I use something like
this will work but I’m using the key as a string which is not ideal I guess? Is there some best practice on how to use Keys safely at compile time? I was thinking about creating an Enum with these keys. But then its still disconnected from the actual StringTable but its easier to change the Key as I would just change the Enum and I dont have to change code. Does this library provide some object with keys as properties or something?
A table entry can be referenced using either the Key Name or ID. Sounds like you want to use the Id.
If you want to reference a single string table entry then the best thing to do is use a LocalizedString. You can then select the value in the editor and at runtime we will use the table Guid and entry Id.
In most cases I would suggest using a LocalizedString. What you are doing is fine and will work as long as the table name and entry is correct, the performance benefit to using Ids over strings is quite small and only worth considering if you are trying to extract a large amount of entries(1000s). The main benefit to using an Id is that if you change the Entry name you wont lose the reference. The Id can be found in the Table Window, Key Id column, if its not visible right click the row headers and enable it.