Preferences screen and some rewrites
Today, I'll talk about progress in preferences screen (and all the relevant changes directly affecting it).
When I started implemented a preferences screen I stumbled on one problem regarding assets mocks. Till now, all the AssetRef were stored in the AssetRefMockerManager GO in the scene. This was sufficient with main menu, as there were practically no prefabs with embedded AssetRefMocker. But as soon I've started working on the preferences screen, the problem appeared: How to handle asset ref mocks inside the prefab when AssetRef is stored in the scene object? So the solution was to store it in the asset ref mocker component itself and then register the instance to the AssetRefMockerManager during Awake(). IAssetRefMocker interface was converted to base class for asset mocks and lot of other changes was done. It should be done like this from the start. Another feature implemented was on-demand loading of the mocks. Till now, all the registered mocks were loaded during the scene load (Start() message). But when you use prefabs, that are instantiated AFTER the scene is loaded, then you have a problem. Therefor, on-demand loading was implemented. The asset is loaded immediately after registering to the AssetRefMockerManager.
Another bigger change was making a BootsrapManager singleton. Because the bootstrap scene is ALWAYS loaded, then it is practical to make it as singleton. This change connects directly with making the SoundManager as a normal MonoBehaviour based class stored in BootsrapManager. Because audio needs scene objects (audio listener, audio sources), there is no need to SoundManager be and ScriptableObject based manager.
The next step was creating the "custom" UI controls needed: Button, Slider and Checkbox.
Regarding the button (Button5State), the one thing that needed to be handled was "disabled" state appearance (this was first implemented using animator an animations, but it was dropped later and implemented in code for simplicity). In JA2 there are 2 options: hatched and shaded. The hatched style was implemented using "checker" texture overlay (as is done in JA2). The shaded was implemented in shader, where the final color was darkened with the predefined shade.
Slider was the one with the minimum work involved as the Unity's Slider was sufficient.
Checkbox (Toggle4State) was also the one, that didn't involved lot of work. But showing the preferences options was.
Now back to the preferences screen as such. The preferences screens show the game options in dynamic way. That is, there is an AssetGameSettingsData class (used as asset), which defines all the options through the GameSettingOptionData class where one can define the text, whether it should be display as the options and so long. In preferences screen, the options are loaded from the file (or generated if it is a first run) and shown in the panel with the scrollbars. In runtime, the GameSettings encapsulate the AssetGameSettingsData and GameSettingOptionValue handles the value set for GameSettingOptionData. This complicated scheme is used because ScriptableObject should define just some immutable data, while the runtime classes uses those data and implemented mutability, serialization and other stuff. The list of options is implemented as a solo view with Aspid.VirtualizedList which is using "view prefab" for it's items (one game setting). Therefor if one needs to add new game settings, it just needs to update AssetGameSettingsData and everything will just work (no need to update UI). The only downside is, that the options aren't shown as in original JA2, where they're shown in 2 columns.
![]() |
| Preferences screen |
There were also some other changes like case-insensitive lookup for keys in INI files and the whole INI handling was rewritten as serialization to the string was also implemented.

Comments