Editable resource dictionaries
Posted: 24 May 2018, 12:35
Hey, I'm working on a system which lets users create their own color schemes to be used by the UI. However, apparently editing a ResourceDictionary is not yet implemented in Noesis: the Add and Remove methods as well as iterating the ResourceDictionary (ICollection, IDictionary and IEnumerable) are currently missing. Would it be possible to add this functionality or is there some other way in which ResourceDictionaries can be edited?
Secondly, part of the color scheme system needs to load XAML files. Currently I've created two ways in which to load XAML files (and then turn them into ResourceDictionaries).
The first method loads the NoesisXAML assets created by NoesisGUI:
The second method loads in a text file. Currently, I'm loading a text file from Unity's Resources folder for testing but the same method should work for files on disk:
I would expect both of these NoesisXaml instances to be the same, but they aren't. The differences are small and both NoesisXaml's produce seemingly working ResourceDictionaries. However, is there a reason why they are different and perhaps not work in certain situations? The differences are:
Kind regards,
Gwynn
Secondly, part of the color scheme system needs to load XAML files. Currently I've created two ways in which to load XAML files (and then turn them into ResourceDictionaries).
The first method loads the NoesisXAML assets created by NoesisGUI:
Code: Select all
NoesisXaml redScheme = (NoesisXaml)Resources.Load("ColorSchemes/Red", typeof(NoesisXaml));
Code: Select all
NoesisXaml redScheme = ScriptableObject.CreateInstance<NoesisXaml>();
redScheme.content = Encoding.ASCII.GetBytes(Resources.Load<TextAsset>("ColorSchemes/Red").text);
redScheme.source = "Assets/Resources/ColorSchemes/Red";
- Most importantly: the content property differs: the NoesisXaml asset contains three more bytes: 239 187 191.
- When loading a NoesisXaml asset the NoesisXaml is already _registered whereas manually loading only sets _registered to true after .Load() has been called.
- The properties fonts, texturePaths, textures and xamls are initialized when loading a NoesisXaml asset (most likely does not matter).
Kind regards,
Gwynn