Exemplo n.º 1
0
        static void UpgradeJsons()
        {
            DirectoryInfo dir   = new DirectoryInfo(CACHE_FILE_PATH.Replace("{filename}.json", ""));
            var           files = dir.GetFiles("*.json");

            foreach (var file in files)
            {
                string content = File.ReadAllText(file.FullName, System.Text.Encoding.UTF8);
                content = content.Replace("UI", "Ui");
                string uiName = file.Name.Replace("XUI", "Ui").Replace(".json", "");
                Debug.Log(uiName);
                UiJsonOld oldJson = Json.Parse <UiJsonOld>(content);
                UiJson    json    = new UiJson();
                json.SaveDirName = oldJson.SaveDirName.Replace("2d", "");
                json.UiNodeData  = new UiNode();
                UiNode node = json.UiNodeData;
                node.Children = new Dictionary <string, UiNode>();
                foreach (var oldData in oldJson.UiNodeDatas)
                {
                    foreach (var oldChild in oldData.Children)
                    {
                        node.Children.Add(oldChild.Key, oldChild.Value);
                    }
                }
                content = Json.ToString(json);
                File.WriteAllText(file.FullName, content, System.Text.Encoding.UTF8);
            }
            Debug.Log("更新Json文件完成。");
        }
Exemplo n.º 2
0
        static void RefreshShowUiNode()
        {
            UiJson jsonData = GetCacheData <UiJson>(ClassName);

            if (jsonData != null)
            {
                if (!string.IsNullOrEmpty(jsonData.SaveDirName))
                {
                    SaveDirName = jsonData.SaveDirName;
                }

                if (jsonData.IsChildUi)
                {
                    IsChildUi = jsonData.IsChildUi;
                    if (!string.IsNullOrEmpty(jsonData.ParentName))
                    {
                        ParentUiName = jsonData.ParentName;
                    }
                }

                if (jsonData.UiNodeData != null)
                {
                    ShowUiNode = ResetUiNode(jsonData.UiNodeData, SceneName);
                }
                else
                {
                    ShowUiNode = GetCacheData <UiNode>(ClassName);
                }
            }

            if (ShowUiNode == null)
            {
                ShowUiNode = new UiNode {
                };
            }

            CheckUiNode(null, ShowUiNode, NewUiNode);
        }
Exemplo n.º 3
0
        public static void SaveCacheData(string className, UiJson jsonData)
        {
            string cachePath = CACHE_FILE_PATH.Replace("{filename}", className);

            File.WriteAllText(cachePath, Json.ToString(jsonData), System.Text.Encoding.UTF8);
        }