Beispiel #1
0
        public static void DumpUI()
        {
            JsonBlueprints.DumpResource(Game.Instance, "UI/Game.json");
            JsonBlueprints.DumpResource(Game.Instance.UI, "UI/Game.UI.json");
            JsonBlueprints.DumpResource(Game.Instance.BlueprintRoot.UIRoot, "UI/Game.BlueprintRoot.UIRoot.json");
            JsonBlueprints.DumpResource(Game.Instance.DialogController, "UI/Game.DialogController.json");
            var ui = Game.Instance.UI;

            foreach (var field in ui.GetType().GetFields())
            {
                try
                {
                    var value = field.GetValue(ui);
                    if (value == null)
                    {
                        Main.DebugLog($"Null field {field.Name}");
                        continue;
                    }
                    JsonBlueprints.DumpResource(value, $"UI/UI.{value.GetType().FullName}.json");
                }
                catch (Exception ex)
                {
                    Main.DebugLog($"Error dumping UI field {field.Name}");
                }
            }
            foreach (var prop in ui.GetType().GetProperties())
            {
                try
                {
                    var value = prop.GetValue(ui);
                    if (value == null)
                    {
                        Main.DebugLog($"Null property {prop.Name}");
                        continue;
                    }
                    JsonBlueprints.DumpResource(value, $"UI/UI.{value.GetType().FullName}.json");
                }
                catch (Exception ex)
                {
                    Main.DebugLog($"Error dumping UI property {prop.Name}");
                }
            }
        }