I have an asset configuration file. It has an App license field, a string with a key is inserted into it. I want to be able to change it during execution. However, I have not found the right way. Can anyone try to edit files of this type?
- Do you want to change this line so that the value is saved the next time you start the application? - M. Green
- @ M.Green not. I keep the value in the database, so I can and without saving - Gnom Skull
- @ M.Green or let it be saved. The main thing that can be changed through the code - Gnom Skull
- Well, just the point is that .asset does not save changes between launches) and therefore clarified. Do you somehow refer to this file at all? Those. somewhere use your field license? Or just ask how would get a link to the file to access the field?) - M. Green
- @ M.Green I am currently working with the vuforia library. The library itself accesses the App license field. But where this happens I have not found. It takes the key from the VuforiaConfiguration.asset file - Gnom Skull
|
2 answers
You can get any file from the Resources folder using the standard Unity static class Resources . Specifically, its method Resources.Load () ;
In your case, you will need something like this:
var path = "..." //путь до файла внутри папки ресурсов, включая имя без формата Resources.Load<...>(path); //Здесь вместо троеточия - тип, который вы ищете
- For my file it does not fit. However, thanks for the help. I found a solution. - Gnom Skull
|
You can change the app license key in runtime mode using the following construction: void Awake () {VuforiaConfiguration.Instance.Vuforia.LicenseKey = "abcde12345 ..."; } But there is a main condition. The key must change in the first scene and before it is loaded. To do this, actually here is the function Awake.
|